NEW
Font size
S
M
L
XL
WorksheetsZero Lessons Test Review
Total questions: 32
Worksheet time: 16mins
Name
Class
Date
1.
What is the output?
System.out.print("abc");
System.out.print("abc");
a)
abc
b)
a
c)
cba
d)
nothing
2.
What is the output?
System.out.print
("a\tc" );
System.out.print
("a\tc" );
a)
a\tc
b)
a c
c)
atc
d)
a\c
3.
What is the output?
public static void main( String args[ ] )
{
}
public static void main( String args[ ] )
{
}
a)
0
b)
main
c)
nothing
d)
args
4.
What is the output?
System.out.print
("ab\\ab" );
System.out.print
("ab\\ab" );
a)
abab
b)
ab
c)
bab
d)
ab\ab
5.
What of the following is not a legal reserved word for a java data type?
a)
integer
b)
double
c)
char
d)
short
6.
What is the output?
String s = "abcdef";
System.out.println(s);
String s = "abcdef";
System.out.println(s);
a)
abc
b)
abcdef
c)
abcde
d)
s
7.
In Java, every program statement ends with a what ?
a)
{
b)
}
c)
)
d)
;
8.
Which of the following is a valid identifier in Java?
a)
123java
b)
main
c)
java1234
d)
}whoot
9.
Which of the following can be used to comment code in Java?
a)
//
b)
[
c)
{*
d)
(
10.
Which of the following is a 32 bit data type?
a)
char
b)
long
c)
double
d)
int
11.
What is the output?
System.out.println
( 7 + " " + 7 );
System.out.println
( 7 + " " + 7 );
a)
14
b)
77
c)
7 7
d)
1 4
12.
What is the output?
System.out.println( 4 + 2 );
System.out.println( 4 + 2 );
a)
6
b)
42
c)
4+2
d)
2
13.
Which of the following lines correctly defines and assigns an integer variable?
a)
int cat = 42;
b)
cat = 42;
c)
int cat = 42
d)
integer cat = 42;
14.
Which of the following lines correctly defines and assigns a double variable?
a)
dog = 42.42;
b)
double = 42;
c)
double = new (42.42);
d)
double dog = 42.42;
15.
Which of the following lines correctly defines and assigns a char variable?
a)
letter = A
b)
char letter = A;
c)
char letter = ‘A’;
d)
char = 'A';
16.
Which of the following lines correctly defines and assigns a String variable?
a)
String stringy = stuff;
b)
stringy = "stuff";
c)
String stringy = "stuff";
d)
String = "stuff";
17.
Which of the following types uses the most memory?
a)
char
b)
short
c)
int
d)
double
18.
Which of the following types uses the least memory?
a)
byte
b)
long
c)
int
d)
double
19.
Never put a semicolon before an open what?
a)
car door
b)
open curly brace {
c)
closed curly brace }
d)
class statement
20.
Which of the following methods would move the cursor down to the next line?
a)
printLINE()
b)
print()
c)
println()
d)
printLn()
21.
Every method must have an open and close what?
a)
period
b)
bracket
c)
curly brace
d)
semicolon
22.
Which of the following is the newline escape sequence?
a)
\t
b)
\\
c)
\nl
d)
\n
23.
Which of the following is the tab character?
a)
\t
b)
\n
c)
\nl
d)
\b
24.
Which of the following would print one backslash on the screen if used in a print( ) or println( )?
a)
\\
b)
\
c)
\\\
d)
/\
25.
What is the output?
int cat = 7;
double dog = cat;
System.out.println(dog);
int cat = 7;
double dog = cat;
System.out.println(dog);
a)
7
b)
7.0
c)
There is no output due to a syntax error
d)
There is no output due to a runtime error
26.
What is the output?
double dog = 4.2;
int cat = dog;
System.out.println(cat);
double dog = 4.2;
int cat = dog;
System.out.println(cat);
a)
4
b)
4.2
c)
There is no output due to a syntax error
d)
There is no output due to a runtime error
27.
What is the ASCII value of ‘b’?
a)
66
b)
48
c)
98
d)
97
28.
What is the ASCII value of ‘B’?
a)
66
b)
97
c)
49
d)
65
29.
What is the output by the code below?
char letter = 67;
System.out.println(letter);
char letter = 67;
System.out.println(letter);
a)
c
b)
67
c)
2
d)
C
30.
Is this a valid indentifier?
ask me
ask me
a)
Yes
b)
No
31.
How many spaces should code be indented?
a)
3
b)
2
c)
7
d)
5
32.
What is the code needed to create a Scanner object?
a)
Scanner = new Scanner(kb);
b)
Scanner kb = new Scanner(in);
c)
Scanner kb = Scanner(in);
d)
kb = new Scanner(in);
Reset
