WorksheetsJava Programming Quiz
Total questions: 10
Worksheet time: 2mins
What is the output?
System.out.println((10 + 20) * 2);
50
60
70
80
What is the result of 5 & 3?
1
2
3
5
What will happen? int[] arr = new int[3]; arr[0] = 10; arr[3] = 20;
arr[3] = 20 stored successfully
Compile time error
Runtime error (ArrayIndexOutOfBoundsException)
Garbage value
Which conversion is allowed implicitly?
int → byte
byte → int
double → int
long → short
What is the output? char c = 'B'; int i = c; System.out.println(i);
B
66
Error
65
What will be the output? float f = 5.5f; int i = (int) f; System.out.println(i);
5
5.5
Error
6
What is the result of 10 | 4?
6
4
10
14
What will happen? String str = null; System.out.println(str.length());
0
NullPointerException
Compile time error
Empty string
What will be the result? boolean flag = true; System.out.println(!flag);
false
true
Error
Null
What will happen? int[] numbers = new int[2]; numbers[2] = 15;
Garbage value
Compile time error
Runtime error (ArrayIndexOutOfBoundsException)
15 stored successfully
