EJB Interview Questions
1 what are Enterprise Java Beans?
Ans: Enterprise Java Beans (EJB) is a specification which defines a component architecture for developing distributed systems. Applications written using the Enterprise JavaBeans architecture are resusable, scalable, transactional, and secure. Enterprise Java Bean’s allow the developer to only focus on implementing the business logic of the application.
2 what is a finder method?
Ans: A method defined in the home interface and invoked by a client to locate an entity bean
3 How many types of Enterprise beans are there and what are they?
Ans: There are 3 types Ebb?s and they are:
1. Entity Bean’s
2. Session Bean’s
3. Message Driven Bean?s (MDB’s)
4 How many types of Entity beans are there and what are they?
Ans: There are 2 types Entity bean’s and they are:
1. Container Managed Persistence (CMP) Entity Bean’s
2. Bean Managed Persistence (BMP) Entity Bean’s
5 How many types of Session beans are there and what are they?
Ans: There are 2 types Session beans and they are:
1. State full Session Bean’s
2. Stateless Session Bean’s
6 How many types of MDB’s are there and what are they?
Ans: There are no different kinds of Message driven beans.
7 How many java files should a developer code to develop a session bean?
Ans: 3 java files has to be provided by the developer. They are:
1) an Home Interface
2) a Remote Interface
3) And a Session Bean implementation class.
8 Explain the role of Home Interface.?
Ans: Home interface contains factory methods for locating, creating and removing instances of EJB’s.
9 Explain the role of Remote Interface.?
Ans: Remote interface defines the business methods callable by a client. All methods defined in the remote interface must throw Remote Exception.
10 what is the need for a separate Home interface and Remote Interface. Can’t they be defined in one interface?
Ans: EJB doesn’t allow the client to directly communicate with an enterprise bean. The client has to use home and remote interfaces for any communication with the bean.The Home Interface is for communicating with the container for bean’s life cycle operations like creating, locating, removing one or more beans. While the remote interface is used for remotely accessing the business methods.
11 what are callback methods?
Ans: Callback methods are bean’s methods, which are called by the container. These are called to notify the bean, of it’s life cycle events.
12 How will you make a session bean as stateful or stateless?
Ans: We have to specify the it in the deployment descriptor (ejb-jar.xml) using <session-type> tag.
13 what is meant by Activation?
Ans: The process of transferring an enterprise bean from secondary storage to memory.
14 what is meant by Passivation?
Ans: The process of transferring an enterprise bean from memory to secondary storage.
15 hat is a re-entrant Entity Bean?
Ans: An re-entrant Entity Bean is one that can handle multiple simultaneous,
interleaved, or nested invocations which will not interfere with each other.
16 Why are ejbActivate () and ejbPassivate () included for stateless session bean even though they are never required as it is a no conversational bean?
Ans: To have a consistent interface, so that there is no different interface that you need to implement for Stateful Session Bean and Stateless Session Bean. Both Stateless and Stateful Session Bean implement javax.ejb.SessionBean and this would not be possible if stateless session bean is to remove ejbActivate and ejbPassivate from the interface.
17 what is an EJB Context?
Ans: EJBContext is an object that allows an enterprise bean to invoke services provided by the container and to obtain the information about the caller of a client-invoked method.
18 Explain the role of EJB Container?
Ans: EJB Container implements the EJB component contract of the J2EE architecture. It provides a runtime environment for enterprise beans that includes security, concurrency, life cycle management, transactions, deployment, naming, and other services. An EJB Container is provided by an EJB Server.
19 what are Entity Bean’s?
Ans: Entity Bean is an enterprise bean that represents persistent data maintained in a atabase. An entity bean can manage its own persistence or can delegate this function to its container. An entity bean is identified by a primary key. If the container in which an entity bean is hosted crashes, the entity bean, its primary key, and any remote references survive the crash.
20 what is a Primary Key?
Ans: Primary Key is an object that uniquely identifies an entity bean within a home.