1. What is a thread in Java?
A thread is a lightweight subprocess, the smallest unit of processing. It allows
concurrent execution of two or more parts of a program for maximum utilization
of CPU.
2. How do you create a thread in Java?
o By extending the Thread class and overriding the run() method.
o By implementing the Runnable interface and defining the run() method.
3. What is the difference between start() and run() methods?
o start() : Creates a new thread and calls the run() method internally.
o run() : Executes in the current thread like a normal method call, without
creating a new thread.
4. What is thread synchronization?
Synchronization ensures that only one thread accesses a critical section of code
at a time, preventing data inconsistency. It is achieved using
the synchronized keyword.
5. What is a daemon thread?
A daemon thread is a background thread that runs in the JVM and terminates
when all user threads finish execution. Example: Garbage Collector.
6. What is the purpose of the join() method?
The join() method allows one thread to wait for the completion of another
thread before proceeding.
7. What is thread priority in Java?
Thread priority determines the order in which threads are scheduled for
execution. It ranges from MIN_PRIORITY (1) to MAX_PRIORITY (10),
with NORM_PRIORITY (5) as the default.
8. What is the sleep() method?
The sleep() method pauses the execution of the current thread for a specified
duration, allowing other threads to execute.
9. What is a thread pool?
A thread pool is a collection of pre-created threads that can be reused to execute
tasks, improving performance by reducing the overhead of thread creation.
10. What is the difference between wait() and sleep() ?
o wait() : Releases the lock and waits until notified, used in
synchronization.
o sleep() : Does not release the lock and pauses the thread for a specified
time.
https://javaconceptoftheday.com/java-threads-interview-questions-and-answers/
https://career.guru99.com/top-40-multithreading-interview-questions-and-answers/
https://www.examveda.com/java-program/practice-mcq-question-on-threads/
JAVA MCQs link
https://www.examveda.com/mcq-question-on-java-program/
Java Interview Programs With Solutions
https://javaconceptoftheday.com/java-interview-programs-with-solutions/
1000 JAVA MCQ
https://www.sanfoundry.com/java-questions-answers-freshers-experienced/