interfacefoo{2.intk=0;3.}4.5.publicclasstestimplementsFoo(6.publicstaticvoidmain(Stringargs[])(7.inti;8.Testtest=newtest();9.i=test.k;10.i=Test.k;11.i=Foo.k;12.)13.)14.Whatistheresult?() A.Compilationsucceeds.B.Anerroratline2causescompilationtofail.C.Anerroratline9causescompilationtofail.D.Anerroratline10causescompilationtofail.E.Anerroratline11causescompilationtofail.
interfacefoo{2.intk=0;3.}4.5.publicclasstestimplementsFoo(6.publicstaticvoidmain(Stringargs[])(7.inti;8.Testtest=newtest();9.i=test.k;10.i=Test.k;11.i=Foo.k;12.)13.)14.Whatistheresult?()
A.Compilationsucceeds.
B.Anerroratline2causescompilationtofail.
C.Anerroratline9causescompilationtofail.
D.Anerroratline10causescompilationtofail.
E.Anerroratline11causescompilationtofail.
相关考题:
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出
publicclasstest(publicintaMethod()[staticinti=0;i++;returnI;)publicstaticvoidmain(Stringargs[]){testtest=newtest();test.aMethod();intj=test.aMethod();System.out.printIn(j);]}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprint“1”D.Compilationwillsucceedandtheprogramwillprint“2”
1.classBar{}1.classTest{2.BardoBar(){3.Barb=newBar();4.returnb;5.}6.publicstaticvoidmain(Stringargs[]){7.Testt=newTest();8.BarnewBar=t.doBar();9.System.out.println(newBar”);10.newBar=newBar();11.System.out.println(finishing”);12.}13.}AtwhatpointistheBarobject,createdonline3,eligibleforgarbagecollection?()A.Afterline8.B.Afterline10.C.Afterline4,whendoBar()completes.D.Afterline11,whenmain()completes.
1.classExc0extendsException{}2.classExc1extendsExc0{}3.publicclassTest{4.publicstaticvoidmain(Stringargs[]){5.try{6.thrownewExc1();7.}catch(Exc0e0){8.System.out.println(Ex0caught”);9.}catch(Exceptione){10.System.out.println(exceptioncaught”);11.}12.}13.}Whatistheresult?()A.Ex0caughtB.exceptioncaughtC.Compilationfailsbecauseofanerroratline2.D.Compilationfailsbecauseofanerroratline6.
publicclassTest{publicintaMethod(){staticinti=0;i++;returni;}publicstaticvoidmain(Stringargs[]){Testtest=newTest();test.aMethod();intj=test.aMethod();System.out.println(j);}}Whatistheresult?() A.0B.1C.2D.Compilationfails.
publicclasstest(publicintaMethod()[staticinti=0;i++;returnI;)publicstaticvoidmain(Stringargs){testtest=newtest();test.aMethod();intj=test.aMethod();System.out.printIn(j);]}Whatistheresult?() A.Compilationwillfail.B.Compilationwillsucceedandtheprogramwillprint“0”C.Compilationwillsucceedandtheprogramwillprint“1”D.Compilationwillsucceedandtheprogramwillprint“2”
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出
下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.
下列代码中,将引起一个编译错误的行是( )。 1)public class Test{ 2)int m,n; 3)public Test{} 4)public Test(int a){m=a;) 5)public static void main(String args[]){ 6)Test tl,t2; 7)int j,k; 8)j=0;k=0; 9)tl=new Test; 10)t2=new Test(j,k); 11)} 12)}A.第3行B.第5行C.第6行D.第l0行