EJB Interview Questions and Answers

    1 Votes


A great collection of frequently asked EJB Interview Questions with best answers for freshers and 2-6 year experienced java programmers and web developers.

1. What is EJB?

Enterprise Java Beans are the server side components that run inside the EJB container and encapsulates the business logic of an enterprise application.

2. What is a J2EE container?

Containers are the interface between a component and the low level platform specific functionality that supports the component. The application server maintains control and provides services through an interface or framework known as a container.

3. What are the types of J2EE container types according to J2EE specification?

There are five defined J2EE container types (three server side and two client side). Three server side containers are as follows:

  • The server itself, which provides the J2EE runtime environment.
  • An EJB container to manage EJB components.
  • A web container to manage servlets and java server pages.

Two client side containers are as follows:

  • An application container for standalone GUIs, console, and batch type programs.
  • An applet container, meaning a browser, usually with the java plug-in.

4. what is a J2EE component and what are its types?

It is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and that communicates with other components. There are three types of components: 

  • Client components, which correlate to the client containers. 
  • Web components - Servlets and JSPs. 
  • EJB components - are business components that run on the server, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance.

5. what are the characterestics of EJB?

  • It hides server side system level issues from developers.
  • It defines a standard component architecture.
  • It can be easily integrated with other EJB components.
  • It enables you to create components and applications that are reusable across various J2EE-compliant servers.

Example: Online Share Trading, Online Library Application, Online Reservation System.

6. what are the controversies with EJB 2.x?

Controversies With EJB 2.x :

  • It is too heavy-weight Its programming model is complex.
  • It does not let you test the code easily.

7. what are the features of EJB 2.0?

Features of EJB 2.0:

  • Integrated support for JMS
  • Support for local interfaces.
  • It's architecture is improved and supports Container Managed Persistence.
  • It supports container managed relationships among entity beans.
  • Enterprise JavaBeans Query Language (EJB QL).
  • Home methods for entity beans.

8. Explain briefly about the EJB components ?

  • EJB Container : It provides runtime environment for the EJB components and services, such as Life cycle management, connection pooling and security.
  • EJB Component : It is a java class that follows the Enterprise Java Bean specification to implement the business logic of an application. Enterprise Java Bean components are deployed in container and are accessed using the remote and home interfaces of an enterprise bean.
  • EJB Object : Enterprise Java Bean container generates Enterprise Java Bean object, when a client needs to access an instance of the enterprise java bean. The Enterprise Java Bean object acts as an interface between the client and bean instances.
  • Remote Interface : It declares methods, which an enterprise bean provides to clients in order to enable them to perform business operations.
  • Home Object : Home objects are generated by Enterprise Java Bean container. Clients access Enterprise Java Bean objects that are stored at different java virtual machine, using the home object.

Task performed by EJB Object

  • Creating EJB objects
  • Searching EJB Objects
  • Removing EJB Objects

EJB Interfaces

  • Home Interface : It declares the various life cycle methods that involve operations, such as creating, finding, removing enterprise beans.
  • Local Interface : These are used when the enterprise bean and the client machine are stored in the same JVM.

9. what are the system services provided by EJB container?

Container provides system services such as:

  • Persistence
  • Security
  • Transaction
  • Connection pooling
  • Component lifecycle management
  • Threading

10. Mention the steps to call a remote method in EJB?

  • The client calls a local stub that is an object of the remote interface.
  • The stub marshals the parameters of the message into a form that can be sent over the network.
  • The call is sent over the network connection to the skeleton that is present at the server.
  • The skeleton demarshals the parameter in a form suitable for calling the EJB object.
  • The skeleton calls the EJB object that provides the middleware services, such as transaction and security.
  • The EJB object calls the instance of enterprise bean.
  • The Enterprise bean instance performs the tasks that are defined in the called method.

11. Mention the steps to call an EJB using local interface?

The client calls a local object. The local object provides services, such as transactions, connection pooling and security. The local object calls the EJB bean instance, which performs the tasks defined in the method. The EJB instance returns the result and control to the local object, which returns the result to the client.

12. what are EJB design principles?

  • EJB applications are loosely coupled.
  • EJB behavior is specified by interfaces.
  • Implementation is hidden from the client.
  • The container supports the application developer.
  • EJB applications are tiered
    • The session tier is the API to the application.
    • The entity tier is the API to the data sources.
Page 1 of 4

Related Articles

JSP Interview Questions and Answers
Servlet Interview Questions and Answers
Advanced Servlet Interview Questions and Answers
Spring Interview Questions and Answers

Popular Videos

How to speak to people

How to speak so that people want to listen.

Got a tip or Question?
Let us know