NEW
Font size
WorksheetsAP Comp
Total questions: 60
Worksheet time: 30mins
What is the output of the code: System.out.println(3+4+""+3-3);
342
345-3
3
72
There is no output due to a compile error
What is the output of the following code: System.out.println(3+4+""+5);
345
there is no output due to a compile error
12
39
75
Which of the following is a newline character?
\b
\n
\t
\r
What of the following is not reserved for a java data type?
char
short
double
integer
float
What is the ASCII value of a '0'?
97
36
48
32
65
which of the following correctly defines a char variable?
char c = a;
char 'a';
char = a;
char c = 'a';
Which of the following types uses the least memory?
long
float
int
char
double
What is output by the following code? System.out.println(3+4+""+5+5);
710
755
340
there is no output due to a compile error
What is the output of the code below? System.out.println( "\"9" );
99
\"9
"9
\
Which of the following types uses the most memory?
short
float
double
int
Which of the lines correctly defines a double variable?
d = 234.1
double d = 234.1;
double = 234.1;
What is the output by the code below?
int num = 5; System.out.println("num");
num
5
num 5
num = 5
Which of the following lines correctly defines a String variable?
String = "cdef";
String s = "cdef";
String s = cdef
String;
What is the output of the code below? System.out.println(3+6);
3
0
9
6
What is the ASCII value of a space?
65
97
32
46
What is the output by the code below? double num = 3.5;
System.out.println("Number: "+num
3.5
There is no output due to a syntax error
Number:
Number: 3.5
What is the output by the following code? System.out.println(3+4+""+5+3);
715
There is no output due to a compile error
36
12
What is the ASCII value of 'B'?
43
97
66
65
What is the output by the code below?
System.out.println(3+" "+3);
3" "3
6" "6
3 3
3
Which of the following is the tab character?
\t
\nl
\r
\n
Every method must have an open and close what?
semicolon
brace
bracket
period
What is the output by the code below?
System.out.println("apl\tus");
apl us
apl\tus
apltus
aplus
What is the output by the code below?
System.out.println("Hello ");
System.out.print("people ");
System.out.println("everywhere ");
Hello people everywhere
Hello
people everywhere
Hello
people
everywhere
Hello people
everywhere
Which of the following methods would move the cursor down to the next line?
prinT()
printLINE()
printLn()
println()
What is the output by the following code?
System.out.print("ap\\lus");
us
aplus
apl\us
ap\lus
Which of the following is a valid identifier in java
(abce
java1234
main
123java
What is the output by the code below?
String x = "Hello";
System.out.println("\String s");
Hello
There is no output due to a syntax error
There is no output due to a runtime error
String s
What is the output by the following code?
String s = "aplus";
System.out.println(s);
aplus
aplu
sulps
s
what is the output by the code below?
double y = 9.0;
int x = y;
System.out.println(x);
There is no output due to a runtime error
9
9.0
Syntax error
What is the output by the code below?
int x = 3;
double y = x;
System.out.println(y);
9
Syntax error
Runtime error
3.0
Which of the following can be used to comment code in java?
//
]*
[*
{*
What is the output by the code below?
char c = 65;
System.out.println(c);
A
a
65
c
What is the output of the code below?
System.out.println(""+3+4+5);
29
12
compile error
345
Which of the following lines correctly defines an integer variable?
int i = 234
i = 234
int i = 234;
integer i = 234;
Never put a semicolon before an open what?
brace
store
bracket
window
What is the ASCII value of 'b'?
98
66
43
97
Which of the following is a 32 bit data type?
short
char
double
int
Which of the following would print one backslash on the screen if used in a print() or println()?
\\
/\
\\\
\b
What is the output by the code below?
int cost = 2.65;
System.out.println("Price: "+cost);
runtime error
syntax error
Price: 2.65
2.65
In java, every statement ends with what?
;
\
]
)
What is output by the code below?
char x = 'A';
x--;
System.out.print(x + 3);
C
D
67
68
What is output by the code below?
System.out.print(7 % 3);
0.5
1
2
3
What is output by the code below?
System.out.println( 5 / 0);
5
0
5.0
There is no output due to a runtime error
What is output by the code below?
double x = 5 / 3;
System.out.print(x);
0
1
1.66
1.0
What is output by the code below?
System.out.print( (double) 4 / 2 );
1
1.0
2.0
2
What is output by the code below?
System.out.print( 9 / 11 );
0.8
1
2
0
What is output by the code below?
System.out.print(15.7 % 5);
0.7
0.3
3
0
What is output by the code below?
System.out.print( (double)3 / 6 );
0.5
1
2
3
What is output by the code below?
int x = 5, y = 6;
int z = x + y;
double a = z;
System.out.print(a);
5
6
11
11.0
What is output by the code below?
int x = 25;
x = x % 5;
System.out.print(x);
0
1
2
3
What is output by the code below?
System.out.println( Math.pow( Math.sqrt(16),3) );
90.0
64.0
81.0
91.0
27.0
What is output by the code below?
System.out.println( Math.abs( -9 ) );
9.0
-10
-9
10
9
What is output by the code below?
System.out.println( Math.pow(3,2) );
6.0
7.0
8.0
9.0
27.0
What is output by the code below?
System.out.println( Math.round( 10 / 4) );
2
3
2.0
3.0
4
What is output by the code below?
System.out.println( Math.ceil(7.1) );
6.0
7.0
8.0
9.0
27.0
What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.two();
test.two();
go
back
goback
gobackback
gobackgobackgoback
What is a method?
a tool that helps organize a program
a tool that complicates a program
a tool that makes a program longer
a tool that makes a program harder to read
a tool that makes a program more disorganized
What is output by the code below?
public class CS
{
public void one()
{
System.out.print("go");
}
public void two()
{
System.out.print("back");
}
}
//code in the main of another class
CS test = new CS();
test.two();
test.one();
test.two();
go
gobackgoback
backgoback
gobackback
gobackgobackgo
What is output by the code below?
public class CS
{
public void one()
{
System.out.print("fun");
}
}
//code in the main of another class
CS test = new CS();
test.one();
fun
funny
funfun
notfun
sofun
What is output by the code below?
public class CS
{
public void one()
{
System.out.print("fun");
}
}
//code in the main of another class
CS test = new CS();
test.one();
test.one();
test.one();
test.one();
fun
funny
funfun
notfun
funfunfunfun
