Question
QUESTION 1 The following code: int fib[][] = {{0, 1, 1}, {2, 3, 5, 8}, {13, 21, 34, 55, 89}}; System.out.print(fib[2][6]); displays 13 displays 8
QUESTION 1
- The following code:
int fib[][] = {{0, 1, 1}, {2, 3, 5, 8}, {13, 21, 34, 55, 89}};
System.out.print(fib[2][6]);
displays 13
displays 8
displays an unknown value
does not compile
throws an Exception at runtime
QUESTION 2
- The following code:
int progressions[][] = {{1, 4, 5}, {2, 5, 1}};
progressions[1] = new int[]{1, 4, 6, 5};
System.out.print(progressions[1][3]);
displays 1
displays 5
displays an unknown value
does not compile
throws an Exception at runtime
QUESTION 3
What does the following code display?
int navigationalDeflector[] = {};
System.out.print(navigationalDeflector.length);
QUESTION 4
What does the following code display?
int tiny[] = new int[3];
try {
tiny[1] = 3;
tiny[2] = 2;
tiny[3] = 1;
System.out.print(tiny[1]);
} catch (ArrayIndexOutOfBoundsException ex) {
System.out.print("Exceptional");
}
QUESTION 5
-
The following code:
int vals[] = {1, 2, 3, 4};
for(int val : vals) {
System.out.print(val * val);
}
displays 1234
displays 1*12*23*34*4
displays 14916
does not compile
throws an Exception at runtime
QUESTION 6
- The following code declares and initializes an ArrayList collection variable that can only store Scanners (you may assume that ArrayList and Scanner have been properly imported)
ArrayList
tsaInventory = new ArrayList (); True or False?
QUESTION 7
-
The following code declares and initializes a one-dimensional array containing three elements
int arr = [1, 2, 3];
True or False?
QUESTION 8
-
A 4-by-7 array like the following
int arr[][] = new int[4][7];
contains:
4 rows and 7 columns
7 rows and 4 columns
3 rows and 6 columns
6 rows and 3 columns
QUESTION 9
-
This is a valid declaration and initialization of a 4-dimensional String array
String inception[][][][] = {{{{"It's gonna get worse as we go deeper."}}}};
True or False?
QUESTION 10
-
What String does answer reference after this code executes?
String multiPass[][] = {{"Leeloo", "Korbin"},{"Zorg", "Ruby"}};
String answer = multiPass[1][0];
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