Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming Concepts Quiz

Total questions: 18

Worksheet time: 9mins

Name
Class
Date
1.

What is method overloading in Java?

a)

Using different method names for the same functionality

b)

Using the same method name with different return types

c)

Using the same method name in different classes

d)

Using the same method name with different parameter types or counts

2.

Which keyword is used to prevent a class from being extended?

a)

private

b)

protected

c)

final

d)

static

3.

What does the 'super' keyword do in Java?

a)

It overrides a method

b)

It defines a static method

c)

It accesses superclass members

d)

It creates a new instance of a class

4.

What is the output of the following code: 'System.out.println(10 + 20);'?

a)

10

b)

20

c)

30

d)

40

5.

What is recursion in programming?

a)

A method that cannot return a value

b)

A method that is called by the main method

c)

A method that calls another method

d)

A method that calls itself

6.

Which of the following is NOT a valid access modifier in Java?

a)

private

b)

public

c)

internal

d)

protected

7.

What is the purpose of the 'final' keyword when applied to a variable?

a)

It allows the variable to be changed

b)

It prevents the variable from being modified

c)

It makes the variable static

d)

It makes the variable accessible only within its class

8.

In Java, what is a nested class?

a)

A class that is defined within another class

b)

A class that extends another class

c)

A class that implements an interface

d)

A class that cannot be instantiated

9.

What is the output of the following code: 'System.out.println(Math.pow(2, 3));'?

a)

10

b)

9

c)

8

d)

6

10.

Which of the following statements about static methods is true?

a)

They can only be called from within the same class

b)

They can be called without creating an instance of the class

c)

They can access instance variables directly

d)

They can access non-static methods

11.

What is the main advantage of method overriding?

a)

It allows a subclass to provide a specific implementation of a method

b)

It prevents a method from being inherited

c)

It allows multiple methods to have the same name

d)

It makes the code more complex

12.

What is the purpose of the parse methods in Java?

a)

To convert strings to other data types

b)

To format output data

c)

To parse JSON data

d)

To read input from the console

13.

Which of the following is a characteristic of a static nested class?

a)

It can be instantiated without an outer class instance

b)

It cannot access static members of the outer class

c)

It requires an instance of the outer class to be created

d)

It can access instance variables of the outer class

14.

What happens if a recursive method does not have a base condition?

a)

It will return a null value

b)

It will cause a stack overflow error

c)

It will terminate immediately

d)

It will execute successfully

15.

What is the output of the following code: 'System.out.println(5 * 5);'?

a)

30

b)

10

c)

15

d)

25

16.

Which of the following statements about inheritance is true?

a)

Inheritance is not supported in Java

b)

A subclass can inherit from multiple superclasses

c)

A superclass cannot be inherited

d)

A subclass can override methods of its superclass

17.

What is the purpose of the 'protected' access modifier?

a)

It allows access from anywhere

b)

It allows access within the same package and subclasses

c)

It restricts access to the class only

d)

It allows access only within the same class

18.

What is the output of the following code: 'System.out.println(10 / 2);'?

a)

20

b)

2

c)

5

d)

10