publicstaticvoidmain(String[]args){Stringstr=null?;if(str==null){System.out.println(”null”);}else(str.length()==0){System.out.println(”zero”);}else{System.out.println(”some”);}}Whatistheresult?() A.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.

publicstaticvoidmain(String[]args){Stringstr=null?;if(str==null){System.out.println(”null”);}else(str.length()==0){System.out.println(”zero”);}else{System.out.println(”some”);}}Whatistheresult?()

A.null

B.zero

C.some

D.Compilationfails.

E.Anexceptionisthrownatruntime.


相关考题:

下面是一段javabean程序,该程序的运行结果是(62)。 public class NullTest { public static void main(String[] args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.append(M++); System.out.println(sb.toString()); } }A.=nullB.=null0C.=null1D.=nullM

● 下面是一段 javabean 程序,该程序的运行结果是 (62) 。public class NullTest{public static void main(String[] args){int M = 0;String str = null;StringBuffer sb = new StringBuffer(“= “);sb.append(str);sb.append(M++);System.out.println(sb.toString());}}(62)A.=nullB.=null0C.=null1D.=nullM

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.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.

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

publicstaticvoidparse(Stringstr){try{floatf=Float.parseFloat(str);}catch(NumberFormatExceptionnfe){f=0;}finally{System.out.println(f);}}publicstaticvoidmain(String[]args){parse(”invalid”);}Whatistheresult?()A.0.0B.Compilationfails.C.AParseExceptionisthrownbytheparsemethodatruntime.D.ANumberFormatExceptionisthrownbytheparsemethodatruntime.

Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)(str.length()10)){3)System.out.println(morethan10);4)}5)elseif((str!=null)(str.length()5)){6)System.out.println(lessthan5);7)}8)else{System.out.println(end);}Whichlinewillcauseerror?()A.line1B.line2C.line5D.line8

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

下面是一段javabean程序,该程序的运行结果是( )。public class NullTest{public static void main(String[]?args){int M=0;String str=null;StringBuffer sb=new StringBuffer("=");sb.append(str);sb.append(M++);System.out.println(sb.toString( ));}}A.=nullB.=null0C.=null1D.=nullM

下面是一段javabean程序,该程序的运行结果是 ( ) 。public class NullTest { public static void main(String[] ?args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.append(M++); System.out.println(sb.toString()); } }A.=nullB.=null0C.=null1D.=nullM