参考答案和解析
参考答案:F
Exceptioninthread"main"java.lang.NullPointerExceptionatX.main(X.java:12)
更多“Stringa=null;a.concat(abc”);a.concat(def”);System.out.println(a);Whatistheresult?() A.abcB.nullC.abcdefD.Compilationfails.E.Thecoderunswithnooutput.F.Anexceptionisthrownatruntime.”相关问题
  • 第1题:

    classTestA{publicvoidstart(){System.out.println(”TestA”);}}publicclassTestBextendsTestA{publicvoidstart(){System.out.println(”TestB”);}publicstaticvoidmain(String[]args){((TestA)newTestB()).start();}}Whatistheresult?()

    A.TestA

    B.TestB

    C.Compilationfails.

    D.Anexceptionisthrownatruntime.


    参考答案:B

  • 第2题:

    Giventhefollowingcode:publicclassPerson{intarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1]);}}Whichstatementiscorrect?()

    A.Whencompilationsomeerrorwilloccur.

    B.Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.

    C.Theoutputiszero.

    D.Theoutputisnull.


    参考答案:A
    实例变量在类的一个实例构造时完成初始化,而且在类的静态方法中不能直接访问类的非静态成员而只能访问类成员(像上题中一样),类的普通方法可以访问类的所有成员和方法,而静态方法只能访问类的静态成员和方法,因为静态方法属于类,而普通方法及成员变量属于类的实例,类方法(静态方法)不能使用属于某个不确定的类的实例的方法和变量,在静态方法里面没有隐含的this,而普通方法有。

  • 第3题:

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

    A.NULL

    B.Compilationfails.

    C.Thecoderunswithnooutput.

    D.Anexceptionisthrownatruntime.


    参考答案:B

    NULLshouldbe"null".

  • 第4题:

    try{intx=0;inty=5/x;}catch(Exceptione){System.out.println(Exception”);}catch(ArithmeticExceptionae){System.out.println(ArithmeticException”);}System.out.println(finished”);Whatistheresult?()

    A.finished

    B.Exception

    C.Compilationfails.

    D.ArithmeticException


    参考答案:D
    ThecorrectanswertothisquestionisD.Whenanintvalueisdividedbyzero,aruntimeexceptionoccurs.Therearenocompilationerrors.

  • 第5题:

    publicclassTest{publicstaticvoidaMethod()throwsException{try{thrownewException();}finally{System.out.println(finally”);}}publicstaticvoidmain(Stringargs[]){try{aMethod();}catch(Exceptione){System.out.println(exception”);}System.out.println(finished”);}}Whatistheresult?()

    A.finally

    B.exceptionfinished

    C.finallyexceptionfinished

    D.Compilationfails.


    参考答案:C

  • 第6题:


    A.abc过程吸热,def过程放热
    B.abc过程放热,def过程吸热
    C.abc过程和def程都吸热
    D.ahc过程和def过程都放热

    答案:A
    解析:

  • 第7题:

    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()

    • A、 null
    • B、 zero
    • C、 some
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第8题:

    vara=[“a”,“b”,“c”];varb=[“d”,“e”,“f”];有a,b两个数组,下面哪个选项可以把a,b合成一个新的数组()。

    • A、全不正确
    • B、varc=a.push()+b.push()
    • C、varc=a.concat(b)
    • D、varc=a.join(b)

    正确答案:C

  • 第9题:

    String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()  

    • A、 abc
    • B、 null
    • C、 abcdef
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:F

  • 第10题:

    319机型救生船存放位置().

    • A、4ABC/DEF、11ABC/DEF、22ABC/DEF
    • B、4ABC、11ABC/DEF、22ABC/DEF
    • C、4ABC/DEF、11DEF、22ABC/DEF
    • D、4ABC/DEF、11ABC/DEF、22DEF

    正确答案:D

  • 第11题:

    单选题
    String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()
    A

     abc

    B

     null

    C

     abcdef

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


    正确答案: D
    解析: Exception in thread "main" java.lang.NullPointerException at X.main(X.java:12) 

  • 第12题:

    单选题
    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()
    A

     null

    B

     zero

    C

     some

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    classParent{Stringone,two;

    classParent{

    Stringone,two;

    publicParent(Stringa,Stringb){

    one=a;

    two=b;}

    publicvoidprint(){System.out.println(one);}}

    publicclassChildextendsParent{

    publicChild(Stringa,Stringb){

    super(a,b);

    }

    publicvoidprint(){

    System.out.println(one+"to"+two);

    }

    publicstaticvoidmain(Stringarg[]){

    Parentp=newParent("south","north");

    Parentt=newChild("east","west");

    p.print();

    t.print();

    }

    }

    Whichofthefollowingiscorrect?()


    参考答案:E
    这个题目涉及继承时的多态性问题,在前面的问题中已经有讲述,要注意的是语句t.print();在运行时t实际指向的是一个Child对象,即java在运行时决定变量的实际类型,而在编译时t是一个Parent对象,因此,如果子类Child中有父类中没有的方法,例如printAll(),那么不能使用t.printAll()。

  • 第14题:

    Stringa=ABCD”;Stringb=a.toLowerCase();b.replace(‘a’,‘d’);b.replace(‘b’,‘c’);System.out.println(b);Whatistheresult?()

    A.abcd

    B.ABCD

    C.dccd

    D.dcba

    E.Compilationfails.

    F.Anexceptionisthrownatruntime.


    参考答案:A

  • 第15题:

    try{if((newObject))(.equals((newObject()))){System.out.println(equal”);}else{System.out.println(notequal”);}}catch(Exceptione){System.out.println(exception”);}Whatistheresult?()

    A.equal

    B.notequal

    C.exception

    D.Compilationfails.


    参考答案:D

  • 第16题:

    booleanbool=true;if(bool=false){System.out.println(“a”);}elseif(bool){System.out.println(“c”);}elseif(!bool){System.out.println(“c”);}else{System.out.println(“d”);}Whatistheresult?()

    A.a

    B.b

    C.c

    D.d

    E.Compilationfails.


    参考答案:C
    Firstofall,thesecondprintlnstatementshouldprintthecharacter‘b’insteadof‘c’.Also,theanswerisnotE.butC.Indeed,thefollowinglineisperfectlylegal:if‘(bool=false)’.TheboolvariablewillsimplytakethevalueoffalseandtheIFstatementwillbeevaluatedtofalse.Therefore,thecorrectanswerisC.

  • 第17题:

    定义一个表示10个值为null的字符串数组,下面选项正确的是( )。

    A.String[]a;

    B.Stringa[];

    C.chara[10][];

    D.Stringa[]=new String[10];


    正确答案:D
    解析: 本题考查字符串数组变量的声明。选项A和选项B的效果是一样的,都是用来定义一个字符串数组,但没有指明数组个数,不满足题目要求。选项C是一个二维的字符数组,在C语言中,一个二维的字符数组就可以表示一个一维的字符串数组,而在Java中,字符char是基本类型,字符串String则是以对象的形式来表示的。选项D正确,它定义了一个含有10个元素的字符串数组,如果没有给字符串数组赋值,则默认为null。

  • 第18题:

    定义一个表示20个值为null的字符串数组,下面选项正确的是()。

    • A、String[]a
    • B、Stringa[]
    • C、chara[20][]
    • D、Stringa[]=newString[20]

    正确答案:D

  • 第19题:

    在Word的编辑状态下,打开文档ABC,修改后另存为DEF,则()

    • A、ABC是当前文档
    • B、DEF是当前文档
    • C、ABC和DEF均是当前文档
    • D、ABC和DEF均不是当前文档

    正确答案:A

  • 第20题:

    vara="A";varx=a.concat("B");x的值是什么()。

    • A、["A","B"]
    • B、AB
    • C、A
    • D、B

    正确答案:B

  • 第21题:

    public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()

    • A、null
    • B、zero
    • C、some
    • D、Compilationfails.
    • E、Anexceptionisthrownatruntime.

    正确答案:D

  • 第22题:

    填空题
    已知△ABC~△DEF,△ABC与△DEF的相似比为4:1,则△ABC与△DEF对应边上的高之比为____.

    正确答案: 4:1
    解析:
    由相似三角形的性质,相似三角形的对应线段的比等于相似比.

  • 第23题:

    单选题
    vara="A";varx=a.concat("B");x的值是什么()。
    A

    [A,B]

    B

    AB

    C

    A

    D

    B


    正确答案: C
    解析: 暂无解析