网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 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”


参考答案

更多 “ 有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 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” ” 相关考题
考题 阅读下面的程序: public class Person{ int arr[ ]=Hew int[10]; public static void main(String args[ ]){ System.out.println(arr[1]); } } 正确的说法是______。A.编译时将产生错误B.编译时正确,运行时将产生错误C.输出为0D.输出为空

考题 阅读下列代码段,选出该代码段的正确文件名( )。 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.javaB.A.classC.B.classD.B.java

考题 阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是( )。A.编译时将产生错误B.编译时正确,运行时将产生错误C.输出零D.输出空

考题 阅读下列代码Public class Person{Static int arr[ ] = new int (10);Public static void main (String args ) {System.out.println(arr[9]);}}该代码运行的结果是A )编译时将产生错误B )编译时正确,运行时将产生错误C )输出 0D )输出空

考题 已知如下代码: public class Test { long a[]=newlong[10]: public static void main(String arg[]){ System.out.println(a[6]): } } 请问哪个语句是正确的( )。A.输出为nullB.输出为0C.编译时出错D.运行时出错

考题 如下两个源程序文件,分别编译后,运行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();}}

考题 阅读下面代码 public class Person { static int arr[]=new int[10]; public static void main(String args) { System.out.println(arr[9]); } } 该代码的运行结果是A.编译时将产生错误B.编译时正确,运行时将产生错误C.输出零D.输出空

考题 给出下列的程序,其叙述正确的是public class Man { static int arr[]= new int [10]; public static void main (String a []){ System.out.println(arr[1]); }}A.编译时将发生错误B.编译时正确但是运行时出错C.输出为0D.输出为null

考题 执行下列代码段之后,变量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.1B.2C.3D.4

考题 阅读下列代码段,选出该代码段的正确的文件名( )。 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.javaB.A.classC.B.classD.B.java

考题 对于下面一段代码的描述中,正确的是______。 public class ex36 { public static void run main(String[] args) throws Excepion { method(); } static void method() throws Exception try { System.out.println("test"); } finally { System.out.println ("finally"); } } }A.代码编译成功,输出“test”和“fmally”B.代码编译成功,输出“test”C.代码实现选项A中的功能,之后Java停止程序运行,抛出异常,但是不进行处理D.代码不能编译

考题 阅读下列代码: public class Person{ static int arr[]=new int[10]; public static void main(String args){ System.out.println{arr[9]); } } 该代码的运行结果是( )。A.编译时将产生错误B.编译时正确,运行时将产生错误C.输出零D.输出空

考题 下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }A.1B.nullC.0D.编译错误

考题 有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z(); } Z() { Z aliasl=this; Z alias2=this; synchronized(aliasl) { try{ alias2.walt(); System.out.println("DONE WAITING"); } catch(InterruptedException e) { System.out.println("INTERR UPTED"); } 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”

考题 给出下面的程序: public class ex49 { static int arr[] = new int[10]; public static void main(String args [] ) { System.out.println (art [1] ); } } ______叙述是正确的。A.编译时将发生错误B.输出为 nullC.输出为0D.编译时正确但是运行时出错

考题 编译和运行以下代码的结果为:public class MyMain{public static void main(String argv){System.out.println("Hello cruel world");}} A.编译错误;B.运行输出 "Hello cruel world";C.编译无错,但运行时指示没有定义构造方法。D.编译无错,但运行时指示没有正确定义main方法。

考题 给出下面代码:public class Person{static int arr[] = new int[10];public static void main(String a[]) {System.out.println(arr[1]);}}以下那个说法正确? A. 编译时将产生错误;B. 编译时正确,运行时将产生错误;C. 输出0;D. 输出null。

考题 设有如下代码:class Base{}public class MyCast extends Base{static boolean b1=false;static int i = -1;static double d = 10.1;public static void main(String argv[]){MyCast m = new MyCast();Base b = new Base();//Here}}则在 //Here处插入哪个代码将不出现编译和运行错误。A.b=m;B.m=b;C.d =i;D.b1 =i;

考题 执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } } A、 nullB、 -1C、 编译时出错D、 运行时报错

考题 阅读以下代码:  public class Test{  public static void main(){  System.out.println(“x=”+x);   } }  请问,代码运行的结果是?() A、 xB、 x=xC、 “x=”+5D、 编译报错

考题 给定如下Java程序片断:  class A{  public A (){   System.out.println("A");  } }  class B extends A{  public B(){  System.out.println("B"); }  public static void main(String[] args){    B b=new B();  } }  上述程序将()。 A、不能通过编译B、通过编译,输出为:A BC、通过编译,输出为:BD、通过编译,输出为:A

考题 现有:  class A  {public String name="a"}  class B extends A {public String name="b"}      执行如下代码后的结果是哪项?()      A a=new B();  System.out.println(a.name);     A、  aB、  bC、编译失败D、运行时抛出异常

考题 现有:      class TestA  {  public void start()  {  System.out.println("TestA");  }     }  public class TestB extends TestA  {  public void start()  {  System.out.println("TestB");  }     public static void main (string[]  args)  (     ((TestA)new TestB()).start();     )     }  运行结果是哪项?()     A、  TeStAB、  TeStBC、编译失败D、运行时抛出异常

考题 单选题现有:  class A  {public String name="a"}  class B extends A {public String name="b"}      执行如下代码后的结果是哪项?()      A a=new B();  System.out.println(a.name);A   aB   bC 编译失败D 运行时抛出异常

考题 单选题阅读以下代码:  public class Test{  public static void main(){  System.out.println(“x=”+x);   } }  请问,代码运行的结果是?()A  xB  x=xC  “x=”+5D  编译报错

考题 单选题给出下面的代码段:public class Base{intw,x,y,z;public Base(inta,intb){x=a;y=b;}public Base(inta,intb,intc,intd){//assignmentx=a,y=bw=d;z=c;}}在代码说明//assignmentx=a,y=b处写入如下哪个代码是正确的?()A Base(a,b)B x=a,y=bC super(a,b)D this(a,b)

考题 单选题下列代码的编译或执行结果是(  )。 public class MyVal{ public static void main(String args[]){ MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean b[] = new Boolean[5]; System.out.println(b[0]); } }A 1B nullC 0D 编译错误

考题 单选题执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } }A  nullB  -1C  编译时出错D  运行时报错