Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Threading and Design Patterns Quiz

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

What is a thread in Java?

a)

A heavy-weight process

b)

A light-weight part of a process

c)

A method for data storage

d)

A type of exception

2.

Which state is a thread in when it is created but not yet started?

a)

Terminated

b)

New

c)

Blocked

d)

Runnable

3.

What method is used to start a thread's execution?

a)

run()

b)

start()

c)

sleep()

d)

join()

4.

What happens when a thread is in the blocked state?

a)

It is waiting for I/O to complete

b)

It is actively running

c)

It has terminated

d)

It is ready to run

5.

Which method allows one thread to wait until another thread completes its execution?

a)

notify()

b)

join()

c)

sleep()

d)

yield()

6.

What is the purpose of the synchronized keyword in Java?

a)

To create new threads

b)

To mark a critical section for thread safety

c)

To terminate threads

d)

To increase thread priority

7.

What is the default priority of the main thread in Java?

a)

1

b)

5

c)

10

d)

3

8.

Which design pattern ensures a class has only one instance?

a)

Adapter Pattern

b)

Singleton Pattern

c)

Factory Pattern

d)

Observer Pattern

9.

What is the role of the thread scheduler in Java?

a)

To terminate threads

b)

To manage thread priorities and execution

c)

To create new threads

d)

To synchronize threads

10.

In the context of multithreading, what does the term 'timed waiting' refer to?

a)

A thread that is actively running

b)

A thread that has terminated

c)

A thread waiting for a specific duration

d)

A thread waiting indefinitely