Java J2ee Struts Hibernate Spring Interview Questions Java J2ee Struts Hibernate Spring Interview Questions
1 2 3 4 5    Next

1. Can you tell the other names for Marker Interface ?

Tagged Interface , Ability Interface , Null Interface , Empty Interface, Blank Interface as it does not contain any fields or methods.

2. What is the Difference between Fail Fast Iterator and Fail Safe Iterator ?

The major difference is fail-safe iterator doesn't throw any Exception, contrary to fail-fast Iterator.
This is because they work on a clone of Collection instead of the original collection and that's why they are called as the fail-safe iterator.

Fail-Fast iterators doesnt allow modifications of a collection while iterating over it.
These iterators throw ConcurrentModificationException if a collection is modified while iterating over it.
They use original collection to traverse over the elements of the collection.
These iterators dont require extra memory as they dont clone.
Ex : Iterators returned by ArrayList, Vector, HashMap.

Fail-Safe iterators allow modifications of a collection while iterating over it.
These iterators don't throw any exceptions if a collection is modified while iterating over it.
They use copy of the original collection to traverse over the elements of the collection.
These iterators require extra memory to clone the collection.
Ex : Iterator returned by ConcurrentHashMap.

3. What Is an Interface ?

The objects in Netscape Application Server applications interact through interfaces. An interface is a description of the services provided by an object. An interface is like a contract between an object and its user (the code that wants to interact with it). The contract describes a set of expected behavior. Code that wants to use an object need only know what interface the object supports; code does not need to know anything about the internal implementation of the object. An interface defines a set of functions, called methods. The interface has no implementation code. It describes only the parameters and return types of its methods. The code for the methods is written separately, in a class, which is said to implement the interface. Typically, the interfaces and their implementations are written by different groups of people. How is an interface different from a class? A class is a set of data and functions (member variables and methods) that define the characteristics of one type of object. An object is an instantiation of a class. An interface, like a class, defines the characteristics of a particular type of object. However, unlike a class, an interface is always abstract. A class can be instantiated to form an object, but an interface can not be instantiated, because it has no implementation code to determine what to do when each method is called. Every interface has a name that serves as an identifier you can refer to in code. By convention, the name of each interface begins with a capital I, for instance, IBuffer.

4. What is a marker interface?

Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. The interface and Cloneable are typical marker interfaces. These do not contain any methods, but classes must implement this interface in order to be serialized and de-serialized.

5. What are daemon threads?

In java we have two type of Threads : Daemon Thread and User Threads. Generally all threads created by programmer are user thread (unless you specify it to be daemon or your parent thread is a daemon thread). User thread are generally meant to run our programm code. JVM doesn't terminates unless all the user thread terminate.

On the other hand we have Daemon threads. Typically these threads are service provider threads. They should not be used to run your program code but some system code. These thread run paralley to your code but survive on the mercy of the JVM. When JVM finds no user threads it stops and all daemon thread terminate instantly. Thus one should never rely on daemon code to perform any program code.

For better understanding consider a well known example of Daemon thread : Java garbage collector. Garbage collector runs as a daemon thread to recalim any unused memory. When all user threads terminates, JVM may stop and garbage collector also terminates instantly.

6. Is Servlet a thread-safe object ?

Yes, Servlet is thread-safe.

7. Can you give few examples for Marker Interfaces ? ,
javax.servlet.SingleThreadModel ,

8. How would you make a copy of an entire Java object with its state?

Have this class implement java.lang.Cloneable interface and overide the method java.lang.Object.clone() method. Note that clone() method does not belongs to Cloneable interface. Cloneable interface is a marker interface.

9. Is Vector thread-safe?

Yes. Vector and Hashtable are thread-safe.

10. What is a green thread ?

Native threads can switch between threads preemptively, switching control from a running thread to a non-running thread at any time. Green threads only switch when control is explicitly given up by a thread (Thread.yield(), Object.wait(), etc.) or a thread performs a blocking operation (read(), etc.). On multi-CPU machines, native threads can run more than one thread simultaneously by assigning different threads to different CPUs. Green threads run on only one CPU. Native threads create the appearance that many Java processes are running: each thread takes up its own entry in the process table. One clue that these are all threads of the same process is that the memory size is identical for all the threads - they are all using the same memory. Unfortunately, this behavior limits the scalability of Java on Linux. The process table is not infinitely large, and processes can only create a limited number of threads before running out of system resources or hitting configured limits.

Java J2ee Struts Hibernate Spring Interview Questions
1 2 3 4 5    Next
Menu - - Java J2ee Struts Spring Hibernate Interview Questions - A home for your website
Ads By Google