WorksheetsJava Programming Quiz
Total questions: 10
Worksheet time: 5mins
Who developed Java and when?
James Gosling, 1991
Bjarne Stroustrup, 1985
Guido van Rossum, 1995
Dennis Ritchie, 1972
Which is not a Java buzzword?
Robust
Secure
Platform Dependent
Object-Oriented
What is the size of an int in Java?
2 bytes
4 bytes
8 bytes
Depends on OS
Output of the code below? int a = 5, b = 2; System.out.println(a / b);
2.5
2
3
Compilation Error
Correct way to declare an array in Java?
int arr[] = new int[5];
int arr = int[5];
arr[] = new int[5];
array int arr[5];
What does this print? int[] nums = {1, 2, 3}; System.out.println(nums[1]);
1
2
3
Compilation Error
Output of this code? int x = 10; x += 5 * 2; System.out.println(x);
20
30
25
15
Correct condition to check if a number is even?
if(num % 2 = 0)
if(num / 2 == 0)
if(num % 2 == 0)
if(num == 2)
What is printed? class Test { public static void main(String[] args) { System.out.println("Hello Java"); } }
Hello Java
Hello
Java
Compilation Error
Which is true about constructors?
Constructors must have a return type
Constructors cannot be overloaded
Constructors initialize objects
Constructors are called manually
