0% found this document useful (0 votes)
14 views2 pages

Short Anser Questions-Java

The document provides an overview of threads in Java, explaining their characteristics, creation methods, and key concepts such as synchronization, daemon threads, and thread priorities. It outlines the differences between important methods like start() and run(), as well as wait() and sleep(). Additionally, it mentions the purpose of thread pools and the join() method for managing thread execution.

Uploaded by

kvsreddycse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Short Anser Questions-Java

The document provides an overview of threads in Java, explaining their characteristics, creation methods, and key concepts such as synchronization, daemon threads, and thread priorities. It outlines the differences between important methods like start() and run(), as well as wait() and sleep(). Additionally, it mentions the purpose of thread pools and the join() method for managing thread execution.

Uploaded by

kvsreddycse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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/

You might also like