当前位置: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.

百度搜索推广每一个Campaign在IP排除设置中最多可以添加多少个IP地址?() 5。 20。 30。 不限。 ()通过对实物的观察进行描绘,可以使幼儿自觉地去注意周围生活中感兴趣的事物,帮助幼儿提升观察能力和专注能力。 儿童对陌生人表现出积极的兴趣,这在依恋类型中属不安全型儿童的表现。 下列进度控制的措施中,属于组织措施的有()。 进行工程进度的风险分析。 落实资金供应的条件。 编制项目进度控制的工作流程。 确定各类进度计划的审批程序。 进行有关进度控制会议的组织设计。 关键词通常不会被部署在哪个地方?() Meta标签。 内容。 锚文本。 JavaScript代码。

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) {} 
 }  

参考答案:

  参考解析

本题暂无解析

在线 客服