publicclassAssertStuff{publicstaticvoidmain(String[]args){intx=5;inty=7;assert(xy):stuff”;System.out.println(”passed”);}}Andthesecommandlineinvocations:javaAssertStuffjava-eaAssertStuffWhatistheresult?()A.passedstuffB.stuffpassedC.passed AnAssertionErroristhrownwiththeword“stuff”addedtothestacktrace.D.passed AnAssertionErroristhrownwithouttheword“stuff”addedtothestacktrace.E.passed AnAssertionExceptionisthrownwiththeword“stuff”addedtothestacktrace.F.passed AnAssertionExceptionisthrownwithouttheword“stuff”addedtothestacktrace.

publicclassAssertStuff{publicstaticvoidmain(String[]args){intx=5;inty=7;assert(x>y):stuff”;System.out.println(”passed”);}}Andthesecommandlineinvocations:javaAssertStuffjava-eaAssertStuffWhatistheresult?()

A.passedstuff

B.stuffpassed

C.passed AnAssertionErroristhrownwiththeword“stuff”addedtothestacktrace.

D.passed AnAssertionErroristhrownwithouttheword“stuff”addedtothestacktrace.

E.passed AnAssertionExceptionisthrownwiththeword“stuff”addedtothestacktrace.

F.passed AnAssertionExceptionisthrownwithouttheword“stuff”addedtothestacktrace.


相关考题:

LessTest{publicstaticvoidmain(String[]args){for(intx=0;x7;++x){inty=2;x=++y;}System.out.println(y=”+y);}}结果为:() A.y=5B.y=6C.y=7D.y=8E.编译失败F.运行时异常被抛出

classFoo{publicstaticvoidmain(String[]args){intx=0;inty=4;for(intz=0;z〈3;z++,x++){if(x〉1++y〈10)y++;}System.out.println(y);}}结果是什么?() A.6B.7C.8D.10

classDemoApp{publicstaticvoidmain(String[]args){intx=5;inty=++x+x++;System.out.println(y=”+y+”,x=”+x);}}以上程序运行后的输出结果是哪项?() A.y=10,x=5B.y=11,x=6C.y=12,x=7D.y=11,x=7

现有:classFoo{publicstaticvoidmain(String[]args){intx=O;inty=4;for(intz=0;z3;Z++;X++){if(x1++y10)y++;}System.out.println(y);}}结果是什么?() A.7B.8C.10D.12

publicclassIfTest(publicstaticvoidmain(string[]args){intx=3;inty=1;if(x=y)system.out.printIn(Notequal”);elsesystem.out.printIn(Equal”);})Whatistheresult?() A.Theoutputis“Equal”B.Theoutputin“NotEqual”C.Anerroratline5causescompilationtofall.D.Theprogramexecutesbutdoesnotprintamessage.

publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?() A.finishedB.Compilationfails.C.AnAssertionErroristhrown.D.AnAssertionErroristhrownandfinishedisoutput.

运行下面程序时,会产生什么异常?() public class X7_1_5 { public static void main(String[] args) { int[] z = {1,2,3,4}; int p = z[4]; int x = 0; int y = p/x; } }A.ArithmeticExceptionB.ArrayIndexOutOfBoundsExceptionC.NumberFormatExceptionD.IOException

运行下面程序时,会产生什么异常?() public class X7_1_5 { public static void main(String[] args) { int[] z = {1,2,3,4}; int p = z[4]; int x = 0; int y = 5/x; } }A.ArithmeticExceptionB.NumberFormatExceptionC.ArrayIndexOutOfBoundsExceptionD.IOException

运行下面程序时,会产生什么异常?() public class X7_1_5 { public static void main(String[] args) { int[] z = {1,2,3,4}; int p = z[4]; int x = 0; int y = 5/x; } }A.NumberFormatExceptionB.ArrayIndexOutOfBoundsExceptionC.IOExceptionD.ArithmeticException