WorksheetsJava Threading and Design Patterns Quiz
Total questions: 10
Worksheet time: 2mins
What is a thread in Java?
A heavy-weight process
A light-weight part of a process
A method for data storage
A type of exception
Which state is a thread in when it is created but not yet started?
Terminated
New
Blocked
Runnable
What method is used to start a thread's execution?
run()
start()
sleep()
join()
What happens when a thread is in the blocked state?
It is waiting for I/O to complete
It is actively running
It has terminated
It is ready to run
Which method allows one thread to wait until another thread completes its execution?
notify()
join()
sleep()
yield()
What is the purpose of the synchronized keyword in Java?
To create new threads
To mark a critical section for thread safety
To terminate threads
To increase thread priority
What is the default priority of the main thread in Java?
1
5
10
3
Which design pattern ensures a class has only one instance?
Adapter Pattern
Singleton Pattern
Factory Pattern
Observer Pattern
What is the role of the thread scheduler in Java?
To terminate threads
To manage thread priorities and execution
To create new threads
To synchronize threads
In the context of multithreading, what does the term 'timed waiting' refer to?
A thread that is actively running
A thread that has terminated
A thread waiting for a specific duration
A thread waiting indefinitely
