第一范文网 - 专业文章范例文档资料分享平台

Java 综合实验及练习(参考答案)

来源:用户分享 时间:2025/6/18 2:55:15 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

D、 List myList=new List();

29器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? ( ) A、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout

30个关键字可以对对象加互斥锁? ( ) A、 transient B、 synchronized C、 serialize D、 static

31Teacher和Student是类Person的子类; Person p; Teacher t; Student s;

//p, t and s are all non-null.

if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是: ( ) A、 将构造一个Student对象; B、 表达式是合法的; C、 表达式是错误的;

D、 编译时正确,但运行时错误。

32行下列程序, 会产生什么结果 ( 自己 )

public class X extends Thread implements Runable{ public void run(){

System.out.println(\ }

public static void main(String args[]) {

Thread t=new Thread(new X()); t.start(); } }

A、 in the Inner outer B、 outer

C、 in the Inner

D、编译不通过

33下面哪个是对字符串String的正确定义 ( )

A、String s1=null; B、String s2=’null’ ; C、String s3=(String) ‘abc’ ; D、String s4=(String) ‘\?’; 34下面哪条语句定义了5个元素的数组( ) A、int [] a={22,23,24,25,12}; B、int a []=new int(5); C、int [5] array; D、int [] arr;

35给出一段程序,选择运行结果 public class sss {

public static void main(String args[]) {

String s1=args[1]; String s2=args[2]; String s3=args[3]; String s4=args[4]; System.out.println(“args[2]=”+s2); } }

命令行执行: java sss 1 2 3 4 结果是下面哪一个?( A、args[2]=2 B、args[2]=null C、args[2]=1 现异常

36下面哪个描述是正确的( )

A、Applet程序中不需要main()方法,也不能有 B、Application程序中可以没有main()方法。 C、Applet程序中可以不定义init( )方法

D、Application程序中必须有run( )方法

37给出一段程序,试判断哪个是正确的结果( ) public class rtExcept{

public static void throwit(){

System.out.print(“throwit”); throw new RuntimeException(); }

public static void main(String [] aa){ try{

System.out.print(“hello “); throwit(); }

catch(Exception re){

System.out.print(“caught ”); } finally{

System.out.print(“finally ”); }

)

D、运行出 System.out.print(“after ”); } }

A、hello throwit caught

B、hello throwit caught finally after C、hello throwit RuntimeException after

D、hello throwit caught finally after RuntimeException

38下面哪个描述是正确的( )

A、Applet程序中不需要main()方法,也不能有 B、Application程序中可以没有main()方法。 C、Applet程序中可以不定义init( )方法 D、Application程序中必须有run( )方法

39面哪个修饰符修饰的变量是所有同一个类生成的对象共享的( ) A、public B、private C、static D、final

40面关于java中类的说法哪个是不正确的( )

A、类体中只能有变量定义和成员方法的定义,不能有其他语句。 B、构造函数是类中的特殊方法。

C、类一定要声明为public的,才可以执行。 D、一个java文件中可以有多个class定义。 41下面程序运行后的输出结果为( ) class A

{static int y=3;

void showy( ){System.out.println(“y=”+y); } } class testA {

public static void main(String aaa []) { A a1=new A( ); A.y+=1; a1.y++; a1.showy( );

} }

输出结果选择:

A、y=3; B、y=4; C、y=5; D、程序运行出错

43在java的一个异常处理中,哪个语句块可以有多个 ( ) A、catch B、finally C、try D、throws

44果希望所有的控件在界面上均匀排列,应使用下列那种布局管理器?( ) A、BoxLayout B、GridLayout C、BorderLayout D、FlowLouLayout 45.给出如下代码:

class Test{

private int m;

public static void fun() { // some code... } }

如何使成员变量m 被函数fun()直接访问? ( ) A、将private int m 改为protected int m B、将private int m 改为 public int m C、将private int m 改为 static int m D、将private int m 改为 int m

45 AB类的一个无形式参数无返回值的方法method书写方法头,使得使用类名AB作为前缀就可以调用它,该方法头的形式为( )。

A. static void method( ) B. public voidmethod( ) C. final void method( ) D. abstract void method( )

46.类Teacher和Student是类Person的子类; Person p; Teacher t; Student s;

//p, t and s are all non-null.

if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是: A、 将构造一个Student对象; B、 表达式是合法的; C、 表达式是错误的;

D、 编译时正确,但运行时错误。

47.对于下列代码:

public class Parent {

public int addValue( int a, int b) { int s; s = a+b; return s; } }

class Child extends Parent { }

下述哪些方法可以加入类Child? ( )

A、 int addValue( int a, int b ){// do something...}

B、 public void addValue (int a, int b ){// do something...} C、 public int addValue( int a ){// do something...}

D、 public int addValue( int a, int b )throws MyException {//do something...}

48.给出下面代码:

public class test{

static int a[] = new a[10];

public static void main(String args[]) { System.out.println(arr[10]); } }

那个选项是正确的? ( )

A、 编译时将产生错误;

B、 编译时正确,运行时将产生错误; C、 输出零; D、 输出空。

49.Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点( )

A 安全性 B 多线程 C 跨平台 D 可移植 50.内部类是在一个类内嵌套定义的类。其特点描述错误的是( ) A.只能在定义它的类或程序段中或表达式内匿名使用,外部使用时必须给出类的全名

B.可以使用它所在类的静态成员变量或实例成员变量,但不可以使用所在类中的局部变量

C.可以作为其它类的成员,而且可访问它所在类的成员 D.除static内部类外,不能在类内声明static成员

搜索更多关于: Java 综合实验及练习(参考答案) 的文档
Java 综合实验及练习(参考答案).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5og1b6x3bs0ne2d1fb2z_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top