Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Dsquad

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What keyword is used to create an object in Java?

a)

create

b)

new

c)

objectify

d)

instance

2.

What does System.out.println("Hello, World!"); do?

a)
It prints 'Hello, World!' to the console.
b)
It deletes 'Hello, World!' from the console.
c)
It saves 'Hello, World!' to a file.
d)
It displays 'Hello, World!' in a popup window.
3.

What does the 'int' keyword represent in Java?

a)

It defines a string variable.

b)

It represents an integer data type.

c)

It is used for floating-point numbers.

d)

It indicates a boolean value.

4.

What is the purpose of the 'public' keyword in Java?

a)

It restricts access to the class.

b)

It allows access from any other class.

c)

It indicates a private variable.

d)

It is used for static methods only.

5.

Which of these is NOT a valid Java identifier? (AKA variable name)

a)

_myVariable

b)

$javaRocks

c)

2cool4Java

d)
  • camelCaseIsLife

6.

What does the 'void' keyword signify in a method declaration?

a)

It indicates that the method returns no value.

b)

It means the method will return an integer.

c)

It specifies that the method is private.

d)

It allows the method to return multiple values.

7.

What is the function of the 'for' loop in Java?

a)

It creates an infinite loop.

b)

It defines a new class.

c)

It is used to declare variables.

d)

It executes a block of code a specific number of times.

8.

What happens if you forget a semicolon (;) in Java?

a)

Java forgives you

b)

Your code runs but with a warning

c)

Compilation error, sadness follows

d)

It fixes itself magically

9.

How many objects are created in this line? String str1 = new String("Java"); String str2 = "Java";

a)

1

b)

2

c)

3

d)

4

10.

What is the output of boolean isJavaFun = true; System.out.println(isJavaFun);?

a)

Yes

b)

No

c)

true

d)

false