black

SCJP程序员认证考试

登录

单项选择题

Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()  
CODE FRAGMENT a:  
public static void main(String args[]) { 
 if (args.length != 0)  
System.out.println(args[args.length-1]); 
 }  
CODE FRAGMENT b:  
public static void main(String args[]) {  
try { System.out.println(args[args.length]); }  
catch (ArrayIndexOutOfBoundsException e) {} 
 }  
CODE FRAGMENT c:  
public static void main(String args[]) {  
int ix = args.length;  
String last = args[ix];  
if (ix != 0) System.out.println(last);  
}  
CODE FRAGMENT d:  
public static void main(String args[]) {  
int ix = args.length-1;  
if (ix > 0) System.out.println(args[ix]); 
 }  
CODE FRAGMENT e:  
public static void main(String args[]) {  
try { System.out.println(args[args.length-1]); 
}catch (NullPointerException e) {} 
 }  

A.Code fragment a.
B.Code fragment b.
C.Code fragment c.
D.Code fragment d.
E.Code fragment e.

相关考题

多项选择题 Whichstatementsdescribeguaranteedbehaviorofthegarbagecollectionandfinalizationmechanisms?()

多项选择题 Whichstatementsconcerningthevalueofamembervariablearetrue,whennoexplicitassignmentshavebeenmade?()

多项选择题 Which statements concerning the relationships between the following classes are true?()   class Foo {  int num;   Baz comp = new Baz();   }   class Bar {  boolean flag;   }   class Baz extends Foo {   Bar thing = new Bar();   double limit;   }

All Rights Reserved 版权所有©建筑考试题库(jzkao.com)

备案号:湘ICP备2020024380号-3