NEW
Font size
WorksheetsJava Basics
Total questions: 25
Worksheet time: 27mins
Which four options describe the correct default values for array elements of the types indicated?
1, 2, 3, 4
1, 3, 4, 5
2, 4, 5, 6
3, 4, 5, 6
Which one of these lists contains only Java programming language keywords?
class, if, void, long, Int, continue
try, virtual, throw, final, volatile, transient
goto, instanceof, native, finally, default, throws
strictfp, constant, super, implements, do
byte, break, assert, switch, include
Which will legally declare, construct, and initialize an array?
int [] myList = {"1", "2", "3"};
int [] myList = (5, 8, 2);
int myList [] [] = {4,9,7,0};
int myList [] = {4, 3, 7};
Which is a valid keyword in java?
interface
string
Float
unsigned
Which three are legal array declarations?
2, 3, 4
2, 4, 5
1, 2, 4
All are correct.
Which three are valid declarations of a float?
1, 2, 4
2, 3, 5
1, 3, 6
2, 4, 6
What is the numerical range of a char?
-128 to 127
-(215) to (215) - 1
0 to 32767
0 to 65535
What will be the output of the program?
12 15
3 4 5 3 7 5
15 15
3 7 5 3 7 5
What will be the output of the program?
true
false
Compilation fails
An exception is thrown at runtime
What will be the output of the program?
small
huge
tiny
Compilation fails
What will be the output of the program?
5 3
6 3
6 4
5 2
What will be the output of the program?
5 3
8 3
8 2
8 5
What will be the output of the program?
0
7
8
14
What will be the output of the program?
ok
ok dokey
dokey
No output is produced
What will be the output of the program?
9 7 7 foo 7 7foo
72 34 34 foo34 34foo
9 7 7 foo34 34foo
72 7 34 foo34 7foo
What will be the output of the program?
7 7
14 0
7 14
14 14
What will be the output of the program?
null null 42
0 0 42
0 42 42
0 0 0
What will be the output of the program?
count = 0
count = 2
count = 3
count = 4
What will be the output of the program?
2
4
8
16
What is the output?
There is a syntax error on line 1.
There are syntax errors on lines 1 and 6.
There are syntax errors on lines 1, 6, and 8.
There is a syntax error on line 6.
What will be the output of the program?
j = -1
j = 0
j = 1
Compilation fails.
What will be the output of the program?
i = 5 and j = 5
i = 6 and j = 5
i = 5 and j = 6
i = 6 and j = 4
What will be the output of the program?
0 2 4
0 2 4 5
0 1 2 3 4
Compilation fails.
What will be the output of the program?
a
b
c
d
Which cause a compiler error?
int[ ] scores = {3, 5, 7};
int [ ][ ] scores = {2,7,6}, {9,3,45};
String cats[ ] = {"Fluffy", "Spot", "Zeus"};
boolean results[ ] = new boolean [] {true, false, true};
Integer results[ ] = {new Integer(3), new Integer(5), new Integer(8)};
