Question
QUESTION 1 Assume double[][] x = new double[4][5], what are x.length and x[2].length? 4 and 4 4 and 5 5 and 4 5 and 5
QUESTION 1
Assume double[][] x = new double[4][5], what are x.length and x[2].length? 4 and 4 4 and 5 5 and 4 5 and 5 1 points Saved QUESTION 2
What is the output of the following code?
System.out.println(indexOfMax); 0 1 2 3 4 1 points Saved QUESTION 3
What is the output of the following code?
1 2 3 4 4 5 6 7 1 3 8 12 2 5 9 13 3 6 10 14 1 points Saved QUESTION 4
In the following code, what is the printout for list1?
1 2 3 1 1 1 0 1 2 0 1 3 1 points Saved QUESTION 5
Assume char[][][] x = new char[14][5][16], what are x.length, x[2].length, and x[0][0].length? 13, 5, and 16 13, 5, and 15 12, 5, and 15 14, 5, and 16 1 points Saved QUESTION 6
Suppose int[] numbers = new int[10], what is numbers[0]? undefined 10 0 null 1 points Saved QUESTION 7
When you create an array using the following statement, the element values are automatically initialized to 0.
int[][] matrix = new int[5][5]; true false 1 points Saved QUESTION 8
Analyze the following code.
The program has a compile error because the size of the array wasn't specified when declaring the array. The program has a runtime error because the array elements are not initialized. The program runs fine and displays x[0] is 0. The program has a runtime error because the array element x[0] is not defined. 1 points Saved QUESTION 9
Analyze the following code:
The program displays 1 2 3 4 The program displays 0 0 The program has a compile error on the statement x = new int[2], because x is final and cannot be changed. The elements in the array x cannot be changed, because x is final. 1 points Saved QUESTION 10
What is the output of the following code?
120 200 16 120 200 14 120 200 20 016 is a compile error. It should be written as 16. 1 points Save Answer QUESTION 11
Which of the following is correct to create an array? int[] m = {1, 2, }; int[] m = {{1, 2}}; int[] m = {{1, 2}, {3, 4}}; int[] m = {1, 2, 3}; 1 points Save Answer QUESTION 12
The arraycopy method does not allocate memory space for the target array. The target array must already be created with memory space allocated. true false 1 points Saved QUESTION 13
Analyze the following code:
The program displays 0 1 2 3 4. The program displays 0 1 2 3 4 and then raises a runtime exception. The program displays 0 1 2 3 4 5. The program displays 0 1 2 3 4 5 and then raises a runtime exception. 1 points Save Answer QUESTION 14
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? 3.1, 3.1, 2.5, 6.4, 2.1 2.5, 3.1, 3.1, 6.4, 2.1 2.1, 2.5, 3.1, 3.1, 6.4 3.1, 3.1, 2.5, 2.1, 6.4 2.1, 3.1, 2.5, 6.4, 3.1 1 points Saved QUESTION 15
Suppose array a is int[] a = {1, 2, 3}, what is a[0] - a[2]? 1 2 3 -1 -2 1 points Saved QUESTION 16
Assume int[][][] x = new char[2][5][3], how many elements are in the array? 30 35 40 45 1 points Saved QUESTION 17
Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length? 2 and 1 2 and 2 3 and 2 2 and 3 3 and 3 1 points Saved QUESTION 18
Analyze the following code:
The program displays 1 2 3 4 5. The program displays 1 2 3 4 5 and then raises an ArrayIndexOutOfBoundsException. The program displays 5 4 3 2 1. The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException. 1 points Save Answer QUESTION 19
What is the printout of the following program?
1 3 5 6 33 1 points Save Answer QUESTION 20
What is the output of the following code?
1 2 3 4 5 6 2 3 4 5 6 6 2 3 4 5 6 1 1 1 1 1 1 1 1 points Save Answer QUESTION 21
Which correctly creates an array of five empty Strings? String[] a = new String [5]; String[] a = {"", "", "", "", ""}; String[5] a; String[ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null); 1 points Saved QUESTION 22
What is the representation of the third element in an array called a? a[2] a(2) a[3] a(3) 1 points Saved QUESTION 23
What is the printout of the following program?
1 3 5 6 33 1 points Save Answer QUESTION 24
Analyze the following code:
The program displays 1 2 3 4 The program displays 0 0 The program displays 0 0 3 4 The program displays 0 0 0 0 1 points Save Answer QUESTION 25
Analyze the following code:
The program has a compile error because new boolean[3][] is wrong. The program has a runtime error because x[2][2] is null. The program runs and displays x[2][2] is null. The program runs and displays x[2][2] is true. The program runs and displays x[2][2] is false. 1 points Save Answer QUESTION 26
Given the following program:
What is the output, if you run the program using the following?
java Test 1 2 3 3 1 1 2 3 1 2 1 points Save Answer QUESTION 27
What would be the result of attempting to compile and run the following code?
The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}. The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3}; The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0}; The program compiles and runs fine and the output "Value is 1.0" is printed. The program compiles and runs fine and the output "Value is 2.0" is printed. 1 points Save Answer QUESTION 28
Suppose a method p has the following heading:
public static int[] p()
What return statement may be used in p()? return 1; return {1, 2, 3}; return int[]{1, 2, 3}; return new int[]{1, 2, 3}; 1 points Save Answer QUESTION 29
Assume int[][] x = {{1, 2, 3}, {3, 4, 5, 5}, {5, 6}}, what are x.length are x[1].length? 2 3 4 5 1 points Save Answer QUESTION 30
Which of the following are valid array declarations? char[] charArray = new char[26]; int[] words = new words[10]; char[] charArray = "Computer Science"; double[3] nums = {3.5, 35.1, 32.0}; 1 points Save Answer QUESTION 31
Given the following declaration:
Which of the following statements is true? The name m represents a two-dimensional array of 30 int values. m[2][4] represents the element stored in the 2nd row and the 4th column of m. m.length has the value 6. m[0].length has the value 5. 1 points Save Answer QUESTION 32
Analyze the following code.
int[] list = new int[5]; list = new int[6]; The code has compile errors because the variable list cannot be changed once it is assigned. The code has runtime errors because the variable list cannot be changed once it is assigned. The code can compile and run fine. The second line assigns a new array to list. The code has compile errors because you cannot assign a different size array to list. 1 points Save Answer QUESTION 33
Analyze the following code:
The program displays 2.5, 3, 4 The program displays 2.5 3 4 The program displays 2.5 3.0 4.0 The program displays 2.5, 3.0 4.0 The program has a syntax error because value is undefined. 1 points Save Answer QUESTION 34
Analyze the following code:
The program displays 0 1 2 3 4. The program displays 4. The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBounds exception. The program has a syntax error because i is not defined in the last statement in the main method. 1 points Save Answer QUESTION 35
What is the index variable for the element at the first row and first column in array a? a[0][0] a[1][1] a[0][1] a[1][0] 1 points Save Answer QUESTION 36
The element in the array must be of a primitive data type. true false 1 points Save Answer QUESTION 37
When you return an array from a method, the method returns ________. a copy of the array a copy of the first element the reference of the array the length of the array 1 points Save Answer QUESTION 38
Which of the following statements are correct? char[][] charArray = {'a', 'b'}; char[2][2] charArray = {{'a', 'b'}, {'c', 'd'}}; char[2][] charArray = {{'a', 'b'}, {'c', 'd'}}; char[][] charArray = {{'a', 'b'}, {'c', 'd'}}; 1 points Save Answer QUESTION 39
Consider the following statements:
int[][] numbers = {{1}, {1, 2}, {1, 2, 3}};
What is numbers.length and what is numbers[1].length? 3, 1 3, 2 3, 3 1, 3 1 points Save Answer QUESTION 40
How many elements are array matrix (int[][] matrix = new int[5][5])? 14 20 25 30
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started