Review Questions |
4.1 |
Given the following declaration, which expression returns the size of the array, assuming the array has been initialized?
int[] array; Select the one correct answer.
|
4.2 |
Is it possible to create arrays of length zero?
Select the one correct answer.
|
4.3 |
Which one of the following array declaration statements is not legal?
Select the one correct answer.
|
4.4 |
Which of these array declaration statements are not legal?
Select the two correct answers.
|
4.5 |
What would be the result of attempting to compile and run the following program?
// Filename: MyClass.java class MyClass { public static void main(String[] args) { int size = 20; int[] arr = new int[ size ]; for (int i = 0; i < size; ++i) { System.out.println(arr[i]); } } } Select the one correct answer.
|
4.6 |
Given the following program, which statement is true?
class MyClass { public static void main(String[] args) { String[] numbers = { "one", "two", "three", "four" }; if (args.length == 0) { System.out.println("no arguments"); } else { System.out.println(numbers[ args.length ] + " arguments"); } } } Select the one correct answer.
|
4.7 |
What would be the result of trying to compile and run the following program?
public class DefaultValuesTest { int[] ia = new int[1]; boolean b; int i; Object o; public static void main(String[] args) { DefaultValuesTest instance = new DefaultValuesTest(); instance.print(); } public void print() { System.out.println(ia[0] + " " + b + " " + i + " " + o); } } Select the one correct answer.
|
3.144.244.250