Assume int[] t = {1, 2, 3, 4}. What is t.length?
查看答案
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);