wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Who developed Java and when?

a)

James Gosling, 1991

b)

Bjarne Stroustrup, 1985

c)

Guido van Rossum, 1995

d)

Dennis Ritchie, 1972

2.

Which is not a Java buzzword?

a)

Robust

b)

Secure

c)

Platform Dependent

d)

Object-Oriented

3.

What is the size of an int in Java?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Depends on OS

4.

Output of the code below? int a = 5, b = 2; System.out.println(a / b);

a)

2.5

b)

2

c)

3

d)

Compilation Error

5.

Correct way to declare an array in Java?

a)

int arr[] = new int[5];

b)

int arr = int[5];

c)

arr[] = new int[5];

d)

array int arr[5];

6.

What does this print? int[] nums = {1, 2, 3}; System.out.println(nums[1]);

a)

1

b)

2

c)

3

d)

Compilation Error

7.

Output of this code? int x = 10; x += 5 * 2; System.out.println(x);

a)

20

b)

30

c)

25

d)

15

8.

Correct condition to check if a number is even?

a)

if(num % 2 = 0)

b)

if(num / 2 == 0)

c)

if(num % 2 == 0)

d)

if(num == 2)

9.

What is printed? class Test { public static void main(String[] args) { System.out.println("Hello Java"); } }

a)

Hello Java

b)

Hello

c)

Java

d)

Compilation Error

10.

Which is true about constructors?

a)

Constructors must have a return type

b)

Constructors cannot be overloaded

c)

Constructors initialize objects

d)

Constructors are called manually