Which code fragments will succeed in printing the last argum

题目
单选题
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.

参考答案和解析
正确答案: D
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

You are developing WPF application for managing student information... btnSort and a DataGrid control named dgStudents on the design surface of the MainWindow.xaml properties : FirstName and LastName. You create the following code segment in the constructor of...The DataGrid control displays the list of students unsorted.You need to ensure that the list of students is sorted by last name.Which code segment should you add to the click event handler of the Button control?()

A.

B.

C.

D.


参考答案:B

第2题:

After plugging in and installing drivers for a wireless bar code reader, which of the following is the LAST step needed to configure the device?()

  • A、Install an inventory tracking application.
  • B、Scan the bar code on the reader’s cradle.
  • C、Enable the device in Device Manager.
  • D、Remove any temporary device drivers.

正确答案:B

第3题:

Which traversal method for a binary tree does the following Pascal code illustrate? Procedure traverse(p:pointer); Begin Ifp<>NIL Then begin Traverse (p^.left); Process(p); Traverse(p^.right) End; End_

A.pre_order

B.middle_order

C.none

D.last_order


正确答案:B

第4题:

Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?()   CODE FRAGMENT a:  int[][] tab = {  { 0, 0, 0 },  { 0, 0, 0 }  };   CODE FRAGMENT b:  int tab[][] = new int[4][];  for (int i=0; i   CODE FRAGMENT c:  int tab[][] = {  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0  };   CODE FRAGMENT d:  int tab[3][2];   CODE FRAGMENT e:  int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };  

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

正确答案:B,E

第5题:

The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()  

  • A、char ch = 65;
  • B、char ch = ’¥65’;
  • C、char ch = ’¥0041’;
  • D、char ch = ’A’;
  • E、char ch = "A";

正确答案:A,D

第6题:

Given: 3.public class MyTagHandler extends TagSupport { 4.public int doStartTag() { 5.// insert code here 6.// return an int 7.} 8.// more code here ... 18.} There is a single attribute foo in the session scope. Which three code fragments,inserted independently atline 5,return the value of the attribute?()

  • A、Object o = pageContext.getAttribute("foo");
  • B、Object o = pageContext.findAttribute("foo");
  • C、Object o = pageContext.getAttribute("foo",PageContext.SESSION_SCOPE);
  • D、HttpSession s = pageContext.getSession();Object o = s.getAttribute("foo");

正确答案:B,C,D

第7题:

Which of the following tools should be used to analyze the placement of file fragments on a mirrored logical volume?()

  • A、 df
  • B、 lslv
  • C、 filemon
  • D、 fileplace

正确答案:D

第8题:

Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? ()

A.

B.

C.

D.

E.

F.


参考答案:A, C

第9题:

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.

正确答案:A

第10题:

Which two code fragments will execute the method doStuff() in a separate thread?()

  • A、new Thread() {public void run() { doStuff(); }};
  • B、new Thread() {public void start() { doStuff(); }};
  • C、new Thread() {public void start() { doStuff(); }}.run();
  • D、new Thread() {public void run() { doStuff(); }}.start();
  • E、new Thread(new Runnable() {public void run() { doStuff(); }}).start();

正确答案:D,E

更多相关问题