JavaSpartans
Java J2ee Struts Hibernate Spring Interview Questions Java J2ee Struts Hibernate Spring Interview Questions
1 2    Next

1. What is a marker interface?

Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. The java.io.Serializable 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.


2. 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.


3. Can you give few examples for Marker Interfaces ?

java.io.Serializable ,
javax.servlet.SingleThreadModel ,
java.rmi.Remote,
javax.ejb.EnterpriseBean,
java.lang.Cloneable,
java.util.EventListener.


4. How many methods are there in the Serializable interface ?

Serializable interface. Serializable is a marker interface (has no data member and method). It is used to 'mark' Java classes so that the objects of these classes may get a certain capability. The Cloneable and Remote are also marker interfaces. It must be implemented by the class whose object you want to persist.


5. 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.


6. Which methods you need to override for implementing serializable interface ?

java.io.Serializable is a marker interface. No methods should be implemented.


7. How to Create a Marker Interface in Java ?


8. where we can use marker interface ?


9. In which situations a Developer can create a Marker Interface


10. What are tag interfaces ?

They are another name for marker interfaces. taged interfaces are interfaces, which have no methods and which gives some special properties to our object through JVM.


Java J2ee Struts Hibernate Spring Interview Questions
1 2    Next
Menu - javaspartans.com - Java J2ee Struts Spring Hibernate Interview Questions
Hostens.com - A home for your website
Ads By Google