EJB Interview Questions and Answers
Question - 61 : - What is the difference between ejbCreate() and ejbPostCreate
Answer - 61 : - The purpose of ejbPostCreate() is to perform clean-up database operations after SQL INSERTs (which occur when ejbCreate() is called) when working with CMP entity beans. ejbCreate() is called before database INSERT operations. You need to use ejbPostCreate() to define operations, like set a flag, after INSERT completes successfully.
Question - 62 : - Why does EJB needs two interfaces(Home and Remote Interface)
Answer - 62 : - Home Interface is the way to communicate with the container which is responsible for creating , locating and removing beans and Remote Interface is the link to the bean that allows acces to all methods and members.
Question - 63 : - What are the optional clauses in EJB QL?
Answer - 63 : - WHERE and ORDERBY clauses are optional in EJB QL where as SELECT and FROM are required clauses.
Question - 64 : - Can I invoke Runtime.gc() in an EJB?
Answer - 64 : - You shouldn’t. What will happen depends on the implementation, but the call will most likely be ignored.
Question - 65 : - What is Remote client view?
Answer - 65 : - The remote client view specification is only available in EJB 2.0. The remote client view of an enterprise bean is location independent. A client running in the same JVM as a bean instance uses the same API to access the bean as a client running in a different JVM on the same or different machine.
Remote interface: The remote interface specifies the remote business methods that a client can call on an enterprise bean.
Remote home interface: The remote home interface specifies the methods used by remote clients for locating, creating, and removing instances of enterprise bean classes.
Question - 66 : - What is Local client view?
Answer - 66 : - The local client view specification is only available in EJB 2.0. Unlike the remote client view, the local client view of a bean is location dependent. Local client view access to an enterprise bean requires both the local client and the enterprise bean that provides the local client view to be in the same JVM. The local client view therefore does not provide the location transparency provided by the remote client view. Local interfaces and local home interfaces provide support for lightweight access from enterprise bean that are local clients. Session and entity beans can be tightly couple with their clients, allowing access without the overhead typically associated with remote method calls.
Question - 67 : - What is EJB client JAR file?
Answer - 67 : - An EJB client JAR file is an optional JAR file that can contain all the class files that a client program needs to use the client view of the enterprise beans that are contained in the EJB JAR file. If you decide not to create a client JAR file for an EJB module, all of the client interface classes will be in the EJB JAR file.
Question - 68 : - What is EJB container?
Answer - 68 : - An EJB container is a run-time environment that manages one or more enterprise beans. The EJB container manages the life cycles of enterprise bean objects, coordinates distributed transactions, and implements object security. Generally, each EJB container is provided by an EJB server and contains a set of enterprise beans that run on the server.
Question - 69 : - What were Entity Beans?
Answer - 69 : -
Entity Beans were presented in the earlier versions of EJB consisting of persistent data in distributed objects.
Question - 70 : - Enlist the Declarative Transaction types?
Answer - 70 : -
They are:
- MANDATORY:
- REQUIRED
- REQUIRES_NEW
- SUPPORTS
- NOT_SUPPORTED
- NEVER