NEW
Font size
WorksheetsJava Review
Total questions: 25
Worksheet time: 8mins
IndexOutOfBoundsException is an exception that occurs when trying to access an array with an index that is either too large or too small.
TRUE
FALSE
Syntax error is a type of compiler error that prevents a program from compiling and creating an executable file with a .class extension.
TRUE
FALSE
Arithmetic Exception is an exception that occurs whenever a wrong mathematical or arithmetic operation appears in the code during run time.
TRUE
FALSE
Variable is an integer contained within square brackets that indicates one of an array’s variables, or elements?
TRUE
FALSE
Parallel array is an array with the same number of elements and for which the values in corresponding elements are related.
TRUE
FALSE
Loop is a collection of multiple values in a single variable with a similar data type?
TRUE
FALSE
The elements of an array are stored in a non-contiguous memory location.
TRUE
FALSE
Logic Errors are classified as a type of runtime error that can result in a program producing an incorrect or unexpected output.
TRUE
FALSE
Try block is a segment of code that can handle an exception that might be thrown by the try block that precedes it.
TRUE
FALSE
Throw statement is the one that sends an Exception out of a block or a method so it can be handled elsewhere?
TRUE
FALSE
Which of the following is not the element of catch block?
Exception type
Pair of parenthesis
Keyword catch
Initialization statement
Which of the following is not the element of try block?
Conditional statement
Keyword try
Opening curly brace
Executable statement
Which of the following is true about array in Java?
Array is a collection of elements that consist various memory locations.
Array is a collection of elements that has no memory locations.
Array is a collection of different type of elements.
Array is a collection of similar type of elements.
Array in Java is index-based, the first element of the array is stored at the _.
0
1
2
3
Refers to the property of array objects that can be used to get the size of the array.
Array index
Array element
Array length
Array count
Which of the following shows the correct example of assigning an elements to a position in an array?
String arrName[] = new String[1];
array[] = {"Kristel"};
arrNames[1] = Kristel;
arrName[0] = 'Kristel';
arrName[0] = "Kristel";
Which of the following statements will print the value stored in the fifth position of the arrNames array?
int arrNames[] = {"Kristel", "Kimberly", "Denmark", "Hanah","Jeraldine", "Eirene" };
System.out.println(arrNames[4]);
System.out.println(arrNames[5]),
System.out.println(arrName[4]),
System.out.println(arrName[5]);
What would be the output of this code?
int month = 5;
switch(month) {
case 1: System.out.println("January"); break;
case 2: System.out.println("February"); break;
case 3: System.out.println("March"); break;
default: System.out.println("May"); break; }
January
February
March
May
What would be the output of this code?
int num[][] = {{1,2,3,4,5,},
{6,7,8,9,10},
{11,12,13,14,15}};
System.out.println(num[2][2]);
11
8
13
10
What would be the output of this code?
int num[][] = {{1,2,3,4,5,},
{6,7,8,9,10},
{11,12,13,14,15}};
System.out.println("Rows: " + num.length);
1
2
3
4
What would be the output of this code?
int num[][] = {{1,2,3,4,5,},
{6,7,8,9,10,11,12},
{13,14,15,16}};
System.out.println("Row 2 has column length of " + num[1].length);
4
5
6
7
What would be the output if the user entered a number 1?
String arrNames[] = {"Kristel", "Kimberly", "Denmark", "Hanah"};
System.out.print("Choose number from 0 to 3: ");
int input = scan.nextInt();
System.out.println("Hello, " + arrNames[input] + "!");
Hello, Kristel!
Hello, Kimberly!
Hello, Denmark!
Hello, Hanah!
What would be the output if the user entered a number 5?
You can only choose a number from 0 to 3!
Hello, Kimberly!
You can only choose a number from 0 to 4!!
Hello, Hanah!
What would be the output if the user entered a number 0?
Hello, Kristel!
Hello, Kimberly!
Hello, Denmark!
Hello, Hanah!
What would be the output if the user entered a letter B?
You can only choose a number from 0 to 4!
Please input only numeric values.
Please input only numeric values!
You can only choose a number from 0 to 4.
