题目内容

The array size is specified when the array is declareD.

A. true
B. false

查看答案
更多问题

Consider the following code fragment: int[] list = new int[10]; for (int i = 0; i <= list.length; i++) {list[i] = (int)(Math.random() * 10); } Which of the following statements is true?

A. The loop body will execute 10 times, filling up the array with zeros.
B. The loop body will execute 10 times, filling up the array with random numbers.
C. list.length must be replaced by 10
D. The code has a runtime error indicating that the array is out of bounD.

Identify the problems in the following code. public class Test {public static void main(String argv[]) {System.out.println("argv.length is " + argv.length);} }

A. The program has a compile error because String argv[] is wrong and it should be replaced by String[] args.
B. If you run this program without passing any arguments, the program would display argv.length is 0.
C. If you run this program without passing any arguments, the program would have a runtime error because argv is null.
D. The program has a compile error because String args[] is wrong and it should be replaced by String args[].

The __________ method copies the sourceArray to the targetArray.

A. System.arrayCopy(sourceArray, 0, targetArray, 0, sourceArray.length);
B. System.arraycopy(sourceArray, 0, targetArray, 0, sourceArray.length);
C. System.copyArrays(sourceArray, 0, targetArray, 0, sourceArray.length);
D. System.copyarrays(sourceArray, 0, targetArray, 0, sourceArray.length);

For the binarySearch method in Section 7.10.2, what is low and high after the first iteration of the while loop when invoking binarySearch(new int[]{1, 4, 6, 8, 10, 15, 20}, 11)?

A. low is 0 and high is 6
B. low is 5 and high is 5
C. low is 6 and high is 5
D. low is 5 and high is 4

答案查题题库