17 java threading interview questions and answers

Java Threading interview questions and answers for freshers and experienced candidates. These interview questions and answers on Java Threading will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. Many candidates appear for the interview for one role - many of the them give the right answers to the questions asked. The one who provides the best answer with a perfect presentation is the one who wins the interview race. The set of Java Threading interview questions here ensures that you offer a perfect answer to the interview questions posed to you.
Ask a question
          

Java threading interview questions and answers


<<Previous  Next>>
1.What is a thread? What are the advantages we derived by programming with thread?

Latest answer: Threads allow programs to execute simultaneously. A thread is an independent path of execution in a program. These threads can be executed synchronously............
Read answer

2.Explain how to create a thread and start it running.

Latest answer: There are 2 ways in which a thread can be created.

By extending the Thread class wherein the subclass needs to override the run method. Then just an instance of that class needs to be created and [classname].start() would start it running.............
Read answer

3.How does thread’s stop method work.

Latest answer: Stop() method of thread stops the thread execution.

The security manager, if present, checks if the current thread is trying to stop some other thread. The stop method to stop the thread is an unsafe option.............
Read answer

4.How do we specify pause times in my program?

Latest answer: Using the sleep function in Java, the thread’s execution can be put on hold. During this pause session, the thread does not loose ownership of the monitors.............
Read answer

5.What is multithreaded program? What is the importance of thread synchronization?

Latest answer: A multithreaded program involves multiple threads of control in a single program. Each thread has its own stack. Other resources of the process are shared by all threads and while trying to access them it should be synchronized.............
Read answer

6.When a thread is created and started, what is its initial state?

Latest answer: A thread is in “Ready” state after it has been created and started.............
Read answer

7.What are the high-level thread states?

Latest answer: The thread can be in one of the following states: Running state: A thread which is in running state has an access to the CPU. This means that the thread is being executed.............
Read answer

8.What is the difference between preemptive scheduling and time slicing?

Latest answer: Under Preemptive scheduling, the task with the highest priority is executed until it enters the waiting or dead states or some other high priority task cones into............
Read answer

9.What is a task's priority and how is it used in scheduling?

Latest answer: Every task is assigned a priority for execution. The task with the highest priority is executed first. The low priority task is executed after that. This task priority is a............
Read answer

10.What is a monitor?

Latest answer: The mechanism that Java uses to support synchronization is the monitor.............
Read answer

11.Explain the use of synchronization keyword.

Latest answer: A method, declared as synchronized, first attains a lock over an object before beginning an execution. Once it has finished with the execution, whether............
Read answer

12.Explain how do we allow one thread to wait while other to finish.

Latest answer: The wait method, notify method, and notifyAll method provide an efficient transfer of control from one thread to another.............
Read answer

13.Explain the purpose of yield method.

Latest answer: The yield method causes the currently executing thread object to temporarily pause and allow other threads to execute.............
Read answer

14.What is the difference between yielding and sleeping?

Latest answer: The sleep() causes the thread to suspend its running only for a specified amount of time.............
Read answer

15.Explain how to create thread in Java.

Answer - We can create Thread in 2 ways in Java.
Read answer

16.Explain the difference between runnable and extends in java.

Answer - We can use Extend Thread class only when the class......
Read answer

17.Explain the term thread safety and synchronization.

Answer - The term Thread safety means each method in a multithreaded.....
Read answer

<<Previous  Next>>

Test your Java skills

Java part 1 (39 questions)
Java part 2 (40 questions)
EJB (20 questions)
JDBC (20 questions)
Applet (20 questions)
Struts (21 questions)
Servlets (20 questions)
Java web services (20 questions)

Also read

OFBiz Service Engine

Defining and creating a Java service
Service parameters
Special unchecked (unmatched) IN/OUT parameters
Security-related programming
Calling services from code (using dispatcher)
IN/OUT parameter mismatch when calling services
Sending feedback; standard return codes success, error and fail
Implementing Service Interfaces
Synchronous and asynchronous services
Using the Service Engine tools
ECAs: Event Condition Actions



Write your comment - Share Knowledge and Experience


 
Interview questions
 
Home | Login | About us | Sitemap | Contact us