JAVA期末考试试题及答案

2026/4/26 2:18:42

二、填空题(每空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)


JAVA期末考试试题及答案.doc 将本文的Word文档下载到电脑
搜索更多关于: JAVA期末考试试题及答案 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219