JAVA语言程序设计期末考试试题和答案

发布时间 : 星期一 文章JAVA语言程序设计期末考试试题和答案更新完毕开始阅读

.

15、在复选框中移动鼠标,然后单击一选项,要捕获所选项必需实现哪个接口?(D) A.ActionListener B.MouseListener C.MouseMotionListern D.ItemListener

二、填空题(每空1分,共20分)

1、面向对象程序设计所具有的基本特征是:___抽象性___,_封装性___,_继承性__,_多态性__ 2、数组x定义如下

int x[ ][ ]=new int[3][2] 则 x..length 的值为____3________, x[0].length 的值为_____2_______。

3、Java中实现多线程一般使用两种方法,一是___继承Thread类_________,二是_____实现Runnable方法__________

4、Java的图形用户界面设计中,有很多布局管理器用来摆放组件的位置,一般用到的布局管理器有(列出四种即可)__FlowLayout_____,___GridLayout_____,__BorderLayout_____,___CardLayout_______

5、Applet常用的方法是:__init()_、__run()__、__stop()__和destroy()。 三、阅读程序,写出程序的输出结果(每题5分,共20分) 1、class A{

private int privateVar; A(int _privateVar){ privateVar=_privateVar; }

boolean isEqualTo(A anotherA){

if(this.privateVar == anotherA.privateVar) return true; else

return false; }

.

.

}

public class B{

public static void main(String args[]){ A a = new A(1); A b = new A(2);

System.out.println(a.isEqualTo(b)); } }

程序的输出结果为:____false_____ 2、class A {

double f(double x, double y) { return x * y; } }

class B extends A {

double f(double x, double y) { return x + y; } }

public class Test {

public static void main(String args[]) { B obj = new B();

System.out.println(\ } }

程序的输出结果为:__ The program output is 10_ 3、public class Unchecked {

public static void main(String[] args) { try { method();

.

.

} catch (Exception e) { System.out.println(\ } finally {

System.out.println(\ } }

static void method() { try { wrench();

System.out.println(\

} catch (ArithmeticException e) { System.out.println(\ } finally {

System.out.println(\ }

System.out.println(\ }

static void wrench() {

throw new NullPointerException(); } }

程序的输出结果为: E A B

4、public class Test {

public static void main(String[] args) { int x;

int a[] = { 0, 0, 0, 0, 0, 0 }; calculate(a, a[5]);

.

.

System.out.println(\ System.out.println(\ }

static int calculate(int x[], int y) { for (int i = 1; i < x.length; i++) if (y < x.length) x[i] = x[i - 1] + 1; return x[0]; } }

程序的输出结果为: the value of a[0] is 0 the value is a[5] is 5

1. 下面哪些是short型的取值范围 [C] A. -27 – 27-1 B. 0 – 216-1 C. -215 – 215-1 D. -231 – 231-1

2. 下面哪些是合法的标识符 [ABE] A. $persons B. TwoUsers C. *point D. this E. _endline

3. 哪些是将一个十六进制值赋值给一个long型变量 [D] A. long number = 345L; B. long number = 0345; C. long number = 0345L;

.

联系合同范文客服:xxxxx#qq.com(#替换为@)