|
|
Interview Questions |
|
|
|
|
Java Interview Questions and Answers (part 4)
Are you a developer? Need to update your software development knowledge or need to prepare for a job interview?
Check out this collection of Java Interview Questions and Answers (part 4)...
Java Interview Questions and Answers (part 4)
- What is Thread in java?
- What is difference between Process and Thread in java?
- How to implement Threads in java?
- Does Thread implements their own Stack, if yes how?
- We should implement Runnable interface or extend Thread class. What are differences between implementing Runnable and extending Thread?
- How can you say Thread behaviour is unpredictable?
- When threads are not lightweight process in java?
- How can you ensure all threads that started from main must end in order in which they started and also main should end in last?
- What is difference between starting thread with run() and start() method?
- What is significance of using Volatile keyword?
- Differences between synchronized and volatile keyword in Java?
- Can you again start Thread?
- What is race condition in multithreading and how can we solve it?
- How threads communicate between each other?
- Why wait(), notify() and notifyAll() are in Object class and not in Thread class?
- Is it important to acquire object lock before calling wait(), notify() and notifyAll()?
- How can you solve consumer producer problem by using wait() and notify() method?
- How can you solve consumer producer pattern by using BlockingQueue?
- What is deadlock in multithreading? Write a program to form DeadLock in multi threading and also how to solve DeadLock situation. What measures you should take to avoid deadlock?
- Have you ever generated thread dumps or analyzed Thread Dumps?
- What is life cycle of Thread, explain thread states? (
- Are you aware of preemptive scheduling and time slicing?
- What are daemon threads?
- Why suspend() and resume() methods are deprecated?
- Why destroy() methods is deprecated?
- As stop() method is deprecated, How can we terminate or stop infinitely running thread in java?
- what is significance of yield() method, what state does it put thread in?
- What is significance of sleep() method in detail, what state does it put thread in ?
- Difference between wait() and sleep() ?
- Differences and similarities between yield() and sleep() ?
- Mention some guidelines to write thread safe code, most important point we must take care of in multithreading programs?
- How thread can enter waiting, sleeping and blocked state and how can they go to runnable state ?
- Difference between notify() and notifyAll() methods, can you write a code to prove your point?
- Does thread leaves object lock when sleep() method is called?
- Does thread leaves object lock when wait() method is called?
- What will happen if we don’t override run method?
- What will happen if we override start method?
- Can we acquire lock on class? What are ways in which you can acquire lock on class?
- Difference between object lock and class lock?
- Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in synchronized method1(), can Thread-2 enter synchronized method2() at same time?
- Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in static synchronized method1(), can Thread-2 enter static synchronized method2() at same time?
- Suppose you have 2 threads (Thread-1 and Thread-2) on same object. Thread-1 is in synchronized method1(), can Thread-2 enter static synchronized method2() at same time?
- Suppose you have thread and it is in synchronized method and now can thread enter other synchronized method from that method?
- Suppose you have thread and it is in static synchronized method and now can thread enter other static synchronized method from that method?
- Suppose you have thread and it is in static synchronized method and now can thread enter other non static synchronized method from that method?
- Suppose you have thread and it is in synchronized method and now can thread enter other static synchronized method from that method?
- Suppose you have 2 threads (Thread-1 on object1 and Thread-2 on object2). Thread-1 is in synchronized method1(), can Thread-2 enter synchronized method2() at same time?
- Suppose you have 2 threads (Thread-1 on object1 and Thread-2 on object2). Thread-1 is in static synchronized method1(), can Thread-2 enter static synchronized method2() at same time?
- Difference between wait() and wait(long timeout), What are thread states when these method are called?
- How can you implement your own Thread Pool in java?
- What is significance of using ThreadLocal?
- What is busy spin?
- Can a constructor be synchronized?
- Can you find whether thread holds lock on object or not?
- What do you mean by thread starvation?
- What is addShutdownHook method in java?
- How you can handle uncaught runtime exception generated in run method?
- What is ThreadGroup in java, What is default priority of newly created threadGroup, mention some important ThreadGroup methods ?
- What are thread priorities?
- Output question 1.
- Output question 2.
- Output question 3.
- Output question 4.
- Output question 5.
- Output question 6.
- Output question 7.
- Output question 8.
- Output question 9.
- Output question 10.
- Output question 12.
- Output question 13.
- Output question 14.
- Output question 15.
- Output question 16.
- Output question 17.
- Output question 18.
- Output question 19.
- Output question 20.
- Output question 21.
- Output question 22.
|
|
|
|
|
|
|
|
|
|