Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Concepts Challenge

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the default value of a boolean variable in Java?

a)

false

b)

null

c)

true

d)

undefined

2.

Which of the following is not a primitive data type in Java?

a)

Integer

b)

String

c)

Character

d)

Float

3.

What is the output of the following code: System.out.println(5 + 3 + "Hello");?

a)

3Hello5

b)

8Hello

c)

Hello8

d)

5Hello3

4.

What keyword is used to create a subclass in Java?

a)

extends

b)

inherits

c)

implements

d)

derives

5.

Which of the following is a valid declaration of a method in Java?

a)

void myMethod()

b)

public myMethod()

c)

public void myMethod()

d)

private void myMethod()

6.

What is the output of the following code: int x = 10; System.out.println(x++);?

a)

10.0

b)

9

c)

10

d)

11

7.

What is encapsulation in Java?

a)

Encapsulation is the use of interfaces to define method signatures.

b)

Encapsulation is the process of converting data types into objects.

c)

Encapsulation is the separation of classes into different packages.

d)

Encapsulation is the bundling of data and methods that operate on that data, restricting direct access to some components.

8.

Which of the following statements is true about constructors in Java?

a)

Constructors can have different names from the class.

b)

Constructors must always return a value.

c)

Constructors can be private and have no parameters.

d)

Constructors in Java have the same name as the class and do not have a return type.

9.

What will be the output of the following code: System.out.println("Hello".length());?

a)

7

b)

6

c)

5

d)

4

10.

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

a)

The 'this' keyword refers to the current instance of a class.

b)

The 'this' keyword is a way to declare variables.

c)

The 'this' keyword refers to a superclass instance.

d)

The 'this' keyword is used for static methods.