wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Programming Quiz

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is not a feature of Java?

a)

Platform independence

b)

Object-oriented

c)

Pointers

d)

Robust

2.

JVM stands for:

a)

Java Variable Machine

b)

Java Virtual Machine

c)

Java Visual Method

d)

Java Verified Machine

3.

Which of the following correctly describes JDK?

a)

It is used to develop and run Java applications.

b)

It is only for compiling Java programs.

c)

It provides only the runtime environment.

d)

It contains only the JVM.

4.

Java was originally developed by:

a)

Microsoft

b)

Sun Microsystems

c)

Google

d)

IBM

5.

The extension of compiled Java bytecode file is:

a)

.java

b)

.class

c)

.jar

d)

.exe

6.

Which method is the entry point for every Java application?

a)

start()

b)

run()

c)

main()

d)

execute()

7.

Which of the following is a valid Java identifier?

a)

123num

b)

num_1

c)

num-1

d)

public

8.

Which data type is used to create a variable that stores text?

a)

String

b)

char

c)

boolean

d)

int

9.

Which operator is used to compare two values in Java?

a)

=

b)

==

c)

:=

d)

equals()

10.

Which keyword is used to define a constant in Java?

a)

const

b)

constant

c)

static

d)

final

11.

What will happen if you do not initialize a local variable in Java?

a)

It will have a default value.

b)

Compilation error.

c)

Runtime error.

d)

It will be initialized to zero.

12.

Which statement is used to exit from a loop in Java?

a)

stop

b)

exit

c)

break

d)

return

13.

Which keyword is used to inherit a class in Java?

a)

implements

b)

extends

c)

inherits

d)

super

14.

What is the purpose of the 'super' keyword?

a)

To call subclass methods

b)

To refer to the parent class object

c)

To define static methods

d)

To define constructors

15.

Which method is used to compare two strings in Java?

a)

==

b)

compareTo()

c)

equalsTo()

d)

equals()

16.

Which of these supports multiple inheritance in Java?

a)

Classes

b)

Interfaces

c)

Abstract classes

d)

Constructors

17.

Abstract classes in Java can have:

a)

Only abstract methods

b)

Only concrete methods

c)

Both abstract and concrete methods

d)

No methods

18.

Which access specifier allows visibility within the same package only?

a)

private

b)

public

c)

protected

d)

default

19.

What does the keyword 'final' prevent when used with a class?

a)

Method overriding

b)

Inheritance

c)

Object creation

d)

Garbage collection

20.

How can you import all classes in a package?

a)

import package.;

b)

include package.;

c)

use package.;

d)

import.;

21.

Which block is always executed regardless of exception?

a)

try

b)

catch

c)

throw

d)

finally

22.

Which exception occurs when dividing by zero?

a)

IOException

b)

ArithmeticException

c)

NullPointerException

d)

NumberFormatException

23.

Which statement is used to manually throw an exception?

a)

throws

b)

try

c)

throw

d)

catch

24.

Checked exceptions are:

a)

Detected at runtime

b)

Detected at compile-time

c)

Ignored by the compiler

d)

None of the above

25.

Which interface must a class implement to create a thread?

a)

Thread

b)

Runnable

c)

Executable

d)

Main

26.

Which method starts the execution of a thread?

a)

run()

b)

start()

c)

execute()

d)

begin()

27.

Which of these methods can stop a running thread?

a)

wait()

b)

terminate()

c)

stop()

d)

exit()

28.

Which method is used for inter-thread communication?

a)

communicate()

b)

wait(), notify(), notifyAll()

c)

run(), start()

d)

sleep(), resume()

29.

What is the default priority of a thread in Java?

a)

1

b)

5

c)

10

d)

0

30.

Which of the following is used to synchronize threads in Java?

a)

synchronized keyword

b)

volatile keyword

c)

static keyword

d)

const keyword