有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z (); } Z() { Z alias1 = this; Z alias2 = this; synchronized(alias1) { try { alias2.wait(); System.out.println("DONE WAITING"); } catch (InterruptedException e) { System.out.println( "INTERRUPTED"); } catch (Exception e) { System.out.println("OTHER EXCEPTION"); } finally { System.out.println ("FINALLY"); } } System.out.println("ALL DONE"); } }
A.应用程序编译正常,但是不打印任何数据
B.应用程序编译正常,并打印数据“DONE WAITING”
C.应用程序编译正常,并打印数据“FINALLY”
D.应用程序编译正常,并打印数据“ALL DONE”
第1题:
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是( )。
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出零
D.输出空
第2题:
已知如下代码: public class Test { long a[]=newlong[10]: public static void main(String arg[]){ System.out.println(a[6]): } } 请问哪个语句是正确的( )。
A.输出为null
B.输出为0
C.编译时出错
D.运行时出错
第3题:
阅读下面的程序: public class Person{ int arr[ ]=Hew int[10]; public static void main(String args[ ]){ System.out.println(arr[1]); } } 正确的说法是______。
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出为0
D.输出为空
第4题:
执行下列代码段之后,变量z的值为______。 Public class Test8 { public static void main(String[] args) { int x=2; int y=3; int z=4; z-....= y-x--; System.out.println(z); }
A.1
B.2
C.3
D.4
第5题:
阅读下面代码 public class Person { static int arr[]=new int[10]; public static void main(String args) { System.out.println(arr[9]); } } 该代码的运行结果是
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出零
D.输出空
第6题:
阅读下列代码
Public class Person{
Static int arr[ ] = new int (10);
Public static void main (String args ) {
System.out.println(arr[9]);
}
}
该代码运行的结果是
A )编译时将产生错误
B )编译时正确,运行时将产生错误
C )输出 0
D )输出空
第7题:
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。
AB.java文件代码如下;
package test;
public class AB
{
int a=60;
public void show()
{
System.out.println(”a=”+a);
}
Example.java文件代码如下:
import test.AB;
class Example
{
public static void main(String args[])
{
AB bj=new AB();
obj.show();
}
}
第8题:
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void methodl() { System.out.println("methodl in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }
A.A.java
B.A.class
C.B.class
D.B.java
第9题:
给出下列的程序,其叙述正确的是public class Man { static int arr[]= new int [10]; public static void main (String a []){ System.out.println(arr[1]); }}
A.编译时将发生错误
B.编译时正确但是运行时出错
C.输出为0
D.输出为null
第10题:
阅读下列代码段,选出该代码段的正确的文件名( )。 class A { void method () { System.out.println ("methodl in class A"); } } public class B { void method2 () { System.out.println("method2 in class B"); } public static void main (String args[]) { System.out.println ("main () in class B"); } }
A.A.java
B.A.class
C.B.class
D.B.java