publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?()A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.

题目
publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?()

A.NULL

B.Compilationfails.

C.Thecoderunswithnooutput.

D.Anexceptionisthrownatruntime.


相似考题
参考答案和解析
参考答案:B

NULLshouldbe"null".

更多“publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?() ”相关问题
  • 第1题:

    publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?()

    A.0

    B.null

    C.Compilationfails.

    D.ANullPointerExceptionisthrownatruntime.

    E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.


    参考答案:D

  • 第2题:

    下面代码的运行结果是( )。 public class ConcatTest { public static void main (String[ ] args) { String str1 = "abc"; String str2 = "ABC"; String str3 = str1. coneat(str2); System. out. println(str3); } }

    A.abc

    B.ABC

    C.abcABC

    D.ABCabc


    正确答案:C
    解析:String类的concat方法原型为public String concat (String str),其功能是将指定字符串连到此字符串的末尾。如果参数字符串的长度为0,则返回此String对象。否则,创建一个新的String对象,用来表示由此String对象表示的字符序列和由参数字符串表示的字符序列串联而成的字符序列。所以本题中的结果为str1和str2串联而成的字符序列,即“abcABC”。

  • 第3题:

    以下程序段输出的结果是() public class test { public static void main(String[] args) { String str = "ABCDE"; str.substring(3); str.concat("XYZ"); System.out.println(str ); } }

    A.DE

    B.DEXYZ

    C.ABCDE

    D.CDEXYZ


    D

  • 第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 Test{ public static void main(String[] args) { String str=”ABCDE”; str.substring(3); str.concat(“XYZ”); System.out.println(str); } }

    A.DE

    B.DEXYZ

    C.ABCDE

    D.CDEXYZ


    D