题目内容

Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?

A. int count = args.length - 1;
B. int count=0; while (!(args[count].equals(""))) count ++;
C. int count = 0; while (args[count] != null) count ++;
D. int count = args.length;

查看答案
更多问题

x.length does not exist if x is null.

A. false
B. true

The array index of the first element in an array is 0.

A. true
B. false

The JVM stores the array in an area of memory, called _______, which is used for dynamic memory allocation where blocks of memory are allocated and freed in an arbitrary order.

A. dynamic memory
B. stack
C. heap
D. memory block

Do the following two programs produce the same result? Program I: public class Test {public static void main(String[] args) {int[] list = {1, 2, 3, 4, 5};reverse(list);for (int i = 0; i < list.length; i++)System.out.print(list[i] + " ");} public static void reverse(int[] list) {int[] newList = new int[list.length]; for (int i = 0; i < list.length; i++)newList[i] = list[list.length - 1 - i]; list = newList;} } Program II: public class Test {public static void main(String[] args) {int[] oldList = {1, 2, 3, 4, 5};reverse(oldList);for (int i = 0; i < oldList.length; i++)System.out.print(oldList[i] + " ");} public static void reverse(int[] list) {int[] newList = new int[list.length]; for (int i = 0; i < list.length; i++)newList[i] = list[list.length - 1 - i]; list = newList;} }

A. No
B. Yes

答案查题题库