题目内容

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

Use the selectionSort method presented in this section to answer this question. Assume list is {3.1, 3.1, 2.5, 6.4, 2.1}, what is the content of list after the first iteration of the outer loop in the method?

A. 2.5, 3.1, 3.1, 6.4, 2.1
B. 3.1, 3.1, 2.5, 2.1, 6.4
C. 3.1, 3.1, 2.5, 6.4, 2.1
D. 2.1, 3.1, 2.5, 6.4, 3.1

Which of the following are valid array declarations?

A. char[] charArray = new char[26];
B. int[] words = new words[10];
C. double[3] nums = {3.5, 35.1, 32.0};
D. char[] charArray = "Computer Science";

答案查题题库