题目内容

When you pass an array to a method, the method receives __________.

A. a copy of the first element
B. a copy of the array
C. the reference of the array
D. the length of the array

查看答案
更多问题

Assume int[] t = {1, 2, 3, 4}. What is t.length?

A. 4
B. 5
C. 0
D. 3

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[].

答案查题题库