Font size
WorksheetsData Types and Operators
Total questions: 26
Worksheet time: 19mins
What will the following code print to the screen
char data = 65;
System.out.println(data);
A
B
C
D
What will the following code print to the screen
char data = 76;
System.out.println(data);
L
M
N
O
What will the following code print to the screen
char data = 90;
System.out.println(data);
W
X
Y
Z
What will the following code print to the screen
char data = 73;
System.out.println(data);
H
J
K
I
What will the following code print to the screen
char data = 84;
System.out.println(data);
S
T
U
V
What will the following code print to the screen
long data = 84.0;
System.out.println(data);
84
84.0
T
What will the following code print to the screen
int data = 84.0;
System.out.println(data);
84
84.0
T
What will the following code print to the screen
byte data = 84.0;
System.out.println(data);
84
84.0
T
What will the following code print to the screen
short data = 84.0;
System.out.println(data);
84
84.0
T
What will the following code print to the screen
float data = 84.0;
System.out.println(data);
84
84.0
T
What will the following code print to the screen
double data = 84.0;
System.out.println(data);
84
84.0
T
What would be the appropriate datatype(s) to replace <var>
<var> data = 306;
System.out.println(data);
byte
short
int
long
float
What would be the appropriate datatype(s) to replace <var>
<var> data = 16;
System.out.println(data);
byte
short
int
long
float
What would be the appropriate datatype(s) to replace <var>
<var> data = 3126154587;
System.out.println(data);
byte
short
int
long
float
What would be the appropriate datatype(s) to replace <var>
<var> data = 3.1415926535;
System.out.println(data);
float
double
byte
int
long
What would be the appropriate datatype(s) to replace <var>
<var> data = 3.141593;
System.out.println(data);
float
double
byte
int
long
What is the answer to the following program?
public static void main (String[] args)
{
double pi = Math.Pi; //3.141593
System.out.format("pi is %.3f%n", pi);
}
Pi is 3.141593
Pi is 3.142
Pi is 3.14
Pi is 3.1
What is the answer to the following program?
public static void main (String[] args)
{
double pi = Math.Pi; //3.141593
System.out.format("pi is %.0f%n", pi);
}
Pi is 3.141593
Pi is 0003.141593
Pi is 3
Pi is 3.0
class MyClass
{
public static void main(String s[])
{
int i = 4;
int j = 21;
int k = ++i * 7 + 2 - j--;
System.out.println("k = " + k);
}
}
k = 16
Error
k = 11
k = 17
a = 2
b = 3 c = 4
d = 1
a = 2
b = 3
c = 4
d = 1
error
a = 1
b = 2
c = 4
d = 2
0
1
2
5
Error
Which is first incremented and then used?
++x
x++
x+
+x
k = 4
Error
k = 6
k = 0
What would be the value of c?
int a = 5;
int b = 3;
int c = a * b++;
int d = a * ++b;
10
15
20
25
What would be the value of d?
int a = 5;
int b = 3;
int c = a * b++;
int d = a * ++b;
10
15
20
25
int i = 11;
i = i++ + ++i;
System.out.println(i);
22
23
24
25
