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

题目

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.


相似考题
更多“publicclassAssertStuff{publicstaticvoidmain(String[]args){intx=5;inty=7;assert(x>y):stu ”相关问题
  • 第1题:

    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.


    参考答案:C

  • 第2题:

    运行下面程序时,会产生什么异常?() 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.ArithmeticException

    B.ArrayIndexOutOfBoundsException

    C.NumberFormatException

    D.IOException


    C

  • 第3题:

    运行下面程序时,会产生什么异常?() 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.NumberFormatException

    B.ArrayIndexOutOfBoundsException

    C.IOException

    D.ArithmeticException


    C

  • 第4题:

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

    A.finished

    B.Compilationfails.

    C.AnAssertionErroristhrown.

    D.AnAssertionErroristhrownandfinishedisoutput.


    参考答案:A

    Thisquestionisabittrickybecauseitlacksthefollowinginformation:Itshouldincludeastatementthatsayswhetherornotassertionsareenabled.Iftheyareindeedenabled,the
    correctionanswerisC.butiftheyarenot,thecorrectanswerisA.Assertionsarenotenabledbydefaultsoifthequestionisnotchanged,themostlogicalanswerisA.

  • 第5题:

    运行下面程序时,会产生什么异常?() 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.ArithmeticException

    B.NumberFormatException

    C.ArrayIndexOutOfBoundsException

    D.IOException


    C