EJB Interview Questions

There is given EJB interview questions and answers that have been asked in many companies. Let's see the list of top EJB interview questions.


1) What is EJB?

EJB stands for Enterprise Java Bean. It is a server-side component to develop scalable, robust and secured enterprise applications in java. More details...


2) What are the types of Enterprise Bean?

There are three types of enterprise bean in java.

  1. Session Bean
  2. Message Driven Bean
  3. Entity Bean
More details...

3) What is session bean?

Session Bean encapsulates business logic. It can be invoked by local, remote or web service client.

There are 3 types of session bean.

  1. Stateless Session Bean
  2. Stateful Session Bean
  3. Singleton Session Bean
More details...

4) What is stateless session bean?

A Stateless session bean is a business object that doesn't maintain the conversational state with the client. More details...


5) Write down the steps for the creation of stateless EJB.

  • Create a local interface.
  • The interface is to be used by the client application.
  • In case the EJB client environment is the same, use @Local annotation.
  • In case the EJB client environment is different, use @Remote annotation.
  • Create a stateful session bean.
  • To signify a stateful bean, use @Stateful annotation.

6) What is stateful session bean?

A Stateful session bean is a business object that maintains the conversational state with the client. More details...


7) What is singleton session bean?

Singleton session bean is instantiated only once for the application. It exists for the life cycle of the application.


8) What is JMS?

Java Message Service is a messaging service to create, send and receive messages asynchronously. More details...


9) What are the advantages of JMS?

  • Asynchronous
  • Reliable
More details...

10) What is PTP model?

In Point to Point model, one message is delivered to one receiver only. Here, Queue is used as a message-oriented middleware. More details...


11) What is Pub/Sub model?

In the Publisher/Subscriber model, one message is delivered to all subscribers. Here, Topic is used as a message-oriented middleware. More details...


12) What is MDB?

Message Driven Bean (MDB) encapsulates business logic. It is invoked by passing the message. It is like JMS receiver. More details...


13) What is Entity Bean?

Entity Bean is a server-side component that represents the persistent data. Since EJB 3.x, it is replaced by JPA. More details...


14) What is Session Facade?

Session Facade is a design pattern to access enterprise bean through the local interface. It abstracts the business object interactions and provides a service layer. It makes the performance fast over the network.


15) List some key actors in persistence API.

Some of the key actors in persistence API are:

  • Entity
  • EntityManager
  • Persistence unit
  • Data source

16) List down the steps for the demonstration of EJP persistence mechanism.

  • Create a database table
  • Create entity classes for the table
  • Create persistent unit and data source
  • Create a stateless EJB
  • Update stateless EJBM
  • Console based application accesses the stateless EJB.

17) Name the attributes of javax.ejb.Stateful.

  • Name
  • mappedName
  • Description

18) Name the attributes of javax.ejb.EJB.

beanInterface

beanName

mappedName


19) Mention the three levels for applying interceptor methods.

  • Default
  • Class
  • Method

20 Mention the Java types that can be mapped using the @Lob annotation.

  • java.sql.Blob
  • String
  • byte[]
  • java.sql.Clob
  • Serializable Object

21) Name the ACID properties of a transaction.

  • Atomic
  • Consistent
  • Isolated
  • Durable