Top 29 Enterprise Java Beans (EJB) Interview Questions You Must Prepare 24.Jun.2024

Q1. What Is Ejbdoclet?

EJBDoclet is an open source JavaDoc doclet that generates a lot of the EJB related source files from custom JavaDoc comments tags embedded in the EJB source file.

Q2. What Is The Difference Between Ejb And Java Be?

EJB is a specification for J2EE server, not a product.
Java be may be a graphical component in IDE.

Q3. What Is Ejb Client Jar File?

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

Q4. What Are The Call Back Methods In Entity Bean?

Callback methods allows the container to notify the bean of events in its life cycle. The callback methods are defined in the javax.ejb.EntityBean interface.

Q5. What Is Software Architecture Of Ejb?

Session and Entity EJBs consist of 4 and 5 parts respetively:
@A remote interface (a client interacts with it).
@A home interface (used for creating objects and for declaring business methods).
@A bean object (an object, which actually performs business logic and EJB-specific operations).
@A deployment descriptor (an XML file containing all information required for maintaining the EJB) or a set of deployment descriptors (if you are using some container-specific features).
5.A Primary Key class - is only Entity bean specific.

Q6. How Many Ejb Objects Are Created For A Bean?

For a Session bean - one EJB object for one bean instance.
For entity bean - it depends , if 2 users are accessing one row at time then one EJB object is used for both the be other wise for each bean one EJB object.

Q7. What Is Re-entrant. Is Session Be Reentrant. Is Entity Be Reentrant?

If we define the entity bean as being reentrant, multiple clients can connect to the Entity bean & execute methods within the entity bean concurrently. Container takes care of synchronization. If we define the entity bean as non-reentrant and many clients connect to it concurrently to execute a method, exception is thrown .


Q8. What Are Traction Isolation Levels In Ejb?

@Traction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise).
@Traction_read_committed- Guarantees that the data you are getting has been committed.
@Traction_repeatable_read - Guarantees that all reads of the database will be the same during the traction (good for read and update operations).
@Traction_serializable- All the tractions for resource are performed serial.

Q9. What Is Ejb Container?

An EJB container is a run-time environment that manages one or more enterprise be. The EJB container manages the life cycles of enterprise bean objects, coordinates distributed tractions, and implements object security. Generally, each EJB container is provided by an EJB server and contains a set of enterprise be that run on the server.


Q10. What Is The Relationship Between Local Interfaces And Container-managed Relationships?

Entity be that have container-managed relationships with other entity be, must be accessed in the same local scope as those related be, and therefore typically provide a local client view. In order to be the target of a container-managed relationship, an entity bean with container-managed persistence must provide a local interface.

Q11. What Is The New Basic Requirement For A Cmp Entity Bean Class In 2.0 From That Of Ejb 1.1?

It must be abstract class. The container extends it and implements methods which are required for managing the relationships

Q12. What Is Ripple Effect?

The process of propagating the changes in the properties of a server group during runtime to all the associated clones is called Ripple Effect.

Q13. What Is Ejb Role In J2ee?

EJB technology is the core of J2EE. It enables developers to write reusable and portable server-side business logic for the J2EE platform.

Q14. What Is Deployment Descriptor?

Deployment descriptor is a XML file. which is used to locate the web applicatio n by includes the details of respective bean.

Q15. What Is Local Client View?

1.The local client view specification is only available in EJB 2.@Unlike the remote client view, the local client view of a bean is location dependent.
2.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.
3.The local client view therefore does not provide the location trparency provided by the remote client view. Local interfaces and local home interfaces provide support for lightweight access from enterprise bean that are local clients.
4.Session and entity be can be tightly couple with their clients, allowing access without the overhead typically associated with remote method calls.


Q16. What Is A Server Group?

A server group is a template of an Application Server(and its contents) i.e, it is a logical representation of the application server. It has the same structure and attributes as the real Application Server, but it is not associated with any node, and does not correspond to any real server process running on any node.

Q17. What Is Message Driven Bean?

1.An MDB is essentially a message consumer that can listen to a message destination or a message endpoint and gets activated when a message arrives.
2.By design, MDBs are anonymous in nature and hence cannot be directly invoked by a client.
3.The only way to invoke an MDB is to send a message to the destination or endpoint to which it is listening.
@As MDBs are stateless in nature and are not related to any specific client, they can be pooled for concurrent processing of messages.


Q18. How Can I Access Ejb From Asp?

We can use the Java 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0, currently downloadable from Sun

Q19. What Is The Difference Between Session And Entity Be?

An entity bean represents persistent global data from the database; a session bean represents trient user-specific data that will die when the user disconnects (ends his session). Generally, the session be implement business methods (e.g. Bank.trferFunds) that call entity be (e.g. Account.deposit, Account.withdraw)

Q20. What Is Enterprise Javabe (ejb) Container?

1.It manages the execution of enterprise be for J2EE applications.
2.Enterprise be and their container run on the J2EE server.

Q21. What Are The Services Provided By Container?

Container services are totally depends upon the “vendor implementation”. But more or less most of the vendors suppots the basic services like,
LifeCycle Management - It is Automatic.
Session Management - it is used by Developer coded callback methods…
Traction Management - it is used by configuring deployment descriptor (DD) .
Security management - it is used by configuring deployment descriptor (DD) .
The other services, if any will be in advanced versions, and depends on Vendor specific.

Q22. Is It Legal To Have Static Initializer Blocks In Ejb?

Although technically it is legal, static initializer blocks are used to execute some piece of code before executing any constructor or method while instantiating a class. Static initializer blocks are also typically used to initialize static fields - which may be illegal in EJB if they are read/write - In EJB this can be achieved by including the code in either the ejbCreate(), setSessionContext() or setEntityContext() methods

Q23. What Is In-memory Replication?

The process by which the contents in the memory of one physical m/c are replicated in all the m/c in the cluster is called in-memory replication.

Q24. Can Entity Be Have No Create() Methods?

Yes. In some cases the data is inserted NOT using Java application, so you may only need to retrieve the information, perform its processing, but not create your own information of this kind.

Q25. What Is A Clone?

The copies of a server group are called Clones. But unlike a Server Group Clones are associated with a node and are real server process running in that node.

Q26. How Ejb Invocation Happens?

1: Retrieve Home Object reference from Naming Service via JNDI.
2: Return Home Object reference to the client.
3: Create me a new EJB Object through Home Object interface.
4: Create EJB Object from the Ejb Object
5: Return EJB Object reference to the client.
6: Invoke business method using EJB Object reference.
7: Delegate request to Bean (Enterprise Bean).


Q27. What Is Ejb Ql?

1.EJB QL is a Query Language provided for navigation across a network of enterprise be and dependent objects defined by me of container managed persistence.
2.EJB QL is introduced in the EJB 2.0 specification.
3.The EJB QL query language defines finder methods for entity be with container managed persistence and is portable across containers and persistence managers.
4.EJB QL is used for queries of two types of finder methods:
               Finder methods that are defined in the home interface of an entity bean and which return entity objects.Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined.

Q28. What Is Remote Client View?

1.The remote client view specification is only available in EJB 2.0.
@The remote client view of an enterprise bean is location independent.
3.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.


Q29. What Are The Types Of Scaling?

There are two types of scaling: Vertical Scaling and Horizontal Scaling.
Vertical Scaling - When multiple server clones of an application server are defined on the same physical m/c, it is called Vertical Scaling. The objective is to use the processing power of that m/c more efficiently.
Horizontal Scaling - When Clones of an application server are defined on multiple physical m/c, it is called Horizontal Scaling. The objective is to use more than one less powerful m/c more efficiently.