Java Interview Questions

1. Why do you want to change the current company?

2. What is the serialization ? why you want to use?

3. What is the super class for all the classes?

4. What are the features of jdk 1.5?

5. What is the checked exception and un checked exception?

6. What is IOC?

7. What is the dependency Injection?

8. What is Java Bean?
Ans:

A Java Bean is a java class that should follow following conventions:

It should have a no-arg constructor.
It should be Serializable.
It should provide methods to set and get the values of the properties, known as getter and setter methods.

According to Java white paper, it is a reusable software component. A bean encapsulates many objects into one object, so we can access this object from multiple places. Moreover, it provides the easy maintenance.

9. What is the producer and consumer problem?

10. what is the difference between the yield() and sleep() and join()?

Ans:

We can prevent a thread from execution by using any of the 3 methods of Thread class:

yield() method pauses the currently executing thread temporarily for giving a chance to the remaining waiting threads of the same priority to execute. If there is no waiting thread or all the waiting threads have a lower priority then the same thread will continue its execution. The yielded thread when it will get the chance for execution is decided by the thread scheduler whose behavior is vendor dependent.

join() If any executing thread t1 calls join() on t2 i.e; t2.join() immediately t1 will enter into waiting state until t2 completes its execution.

sleep() Based on our requirement we can make a thread to be in sleeping state for a specified period of time (hope not much explanation required for our favorite method).

Search This Blog

All the rights are reserved to this blog is belongs to me only.. Powered by Blogger.