publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?() A.finishedB.Compilationfails.C.AnAssertionErroristhrown.D.AnAssertionErroristhrownandfinishedisoutput.
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?()
A.finished
B.Compilationfails.
C.AnAssertionErroristhrown.
D.AnAssertionErroristhrownandfinishedisoutput.
相关考题:
publicstaticvoidmain(String[]args){try{args=null;args[0]=test”;System.out.println(args[0]);}catch(Exceptionex){System.out.println(”Exception”);}catch(NullPointerExceptionnpe){System.out.println(”NullPointerException”);}}Whatistheresult?()A.testB.ExceptionC.Compilationfails.D.NullPointerException
publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?() A.Compilationfails.B.Compilationsucceedswitherrors.C.Compilationsucceedswithwarnings.D.Compilationsucceedswithoutwarningsorerrors.
下列语句序列执行后,x的值是_________。publicclasstest{publicstaticvoidmain(string[]args){inta=2;intb=3;intx=4;x=++a*x;system.out.println(x);}} A.13B.10C.11D.12
publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?() A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.
publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?() A.0B.nullC.Compilationfails.D.ANullPointerExceptionisthrownatruntime.E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x0)?assertionfailed”:assertionpassed”;System.out.println(Finished”);}}Whatistheresult?() A.finishedB.Compilationfails.C.AnAssertionErroristhrownandfinishedisoutput.D.AnAssertionErroristhrownwiththemessage“assertionfailed”.E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
packagetest1;publicclassTest1{staticintx=42;}packagetest2;publicclassTest2extendstest1.Test1{publicstaticvoidmain(String[]args){System.out.println(x=+x);}}Whatistheresult?() A.x=0B.x=42C.Compilationfailsbecauseofanerrorinline2ofclassTest2.D.Compilationfailsbecauseofanerrorinline3ofclassTest1.E.Compilationfailsbecauseofanerrorinline4ofclassTest2.
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x A.跳出循环,无输出B.0121C.01D.0123