网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0)?assertionfailed”:assertionpassed”;System.out.println(Finished”);}}Whatistheresult?()
A.finished
B.Compilationfails.
C.AnAssertionErroristhrownandfinishedisoutput.
D.AnAssertionErroristhrownwiththemessage“assertionfailed”.
E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
参考答案
更多 “ 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”. ” 相关考题
考题
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.
考题
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(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?()
A.finishedB.Compilationfails.C.AnAssertionErroristhrown.D.AnAssertionErroristhrownandfinishedisoutput.
考题
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.
考题
阅读下面代码 public class Test { public static void main(String[]args) { System.out.println(2>0?10:8); } } 其运行的结果是A.2B.0C.10D.8
考题
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
热门标签
最新试卷