Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

1.What is EJB?

EJB stands for Enterprise Java Beans. EJB is an essential part of a J2EE platform. J2EE platform have component based architecture to provide multi-tiered, distributed and highly transactional features to enterprise level applications.
EJB provides an architecture to develop and deploy component based enterprise applications considering robustness, high scalability and high performance. An EJB application can be deployed on any of the application server compliant with J2EE 1.3 standard specification.

2.What are the benefits of EJB?

Following are the key benefits of EJB.

  • Simplified development of large scale enterprise level application.
  • Application Server/ EJB container provides most of the system level services like transaction handling, logging, load balancing, persistence mechanism, exception handling and so on. Developer has to focus only on business logic of the application.
  • EJB container manages life cycle of ejb instances thus developer needs not to worry about when to create/delete ejb objects.

3.What is a Session Bean in EJB?

Session bean stores data of a particular user for a single session. It can be stateful or stateless. It is less resource intensive as compared to entity beans. Session bean gets destroyed as soon as user session terminates.

4.What is Stateful Session Bean in EJB?

A stateful session bean is a type of enterprise bean which preserve the conversational state with client. A stateful session bean as per its name keeps associated client state in its instance variables. EJB Container creates a separate stateful session bean to process client's each request. As soon as request scope is over, statelful session bean is destroyed.

5.What is Stateless Session Bean in EJB?

A stateless session bean is a type of enterprise bean which is normally used to do independent operations. A stateless session bean as per its name does not have any associated client state, but it may preserve its instance state. EJB Container normally creates a pool of few stateless bean's objects and use these objects to process client's request. Because of pool, instance variable values are not guaranteed to be same across lookups/method calls.

6.What is Entity Bean in EJB?

Entity beans represents persistent data storage. User data can be saved to database via entity beans and later on can be retrived from the database in the entity bean.

7.What is Message Driven Bean in EJB?

A message driven bean is a type of enterprise bean which is invoked by EJB container when it receives a message from queue or topic. Message driven bean is a stateless bean and is used to do task asynchronously.

8.When a local session bean is used in EJB?

If ejb client is in same environment where ejb session bean is to be deployed then we use local session bean.

9.What a remote session bean is used in EJB?

if ejb client is in different environment where ejb session bean is to be deployed then we use remote session bean.

10.What are the differences between stateful session bean and stateless session bean?

Following are the differences between stateful session bean and stateless session bean:

  • EJB Container creates a separate stateful session bean to process client's each request.whereas EJB Container normally creates a pool of few stateless bean's objects and use these objects to process client's request.
  • As soon as request scope is over, statelful session bean is destroyed but stateless bean remains active.
  • A stateful session bean is a type of enterprise bean which preserve the conversational state with client. A stateful session bean as per its name keeps associated client state in its instance variables Whereas because of pool of stateless session beans, instance variable values are not guaranteed to be same across lookups/method calls in stateless session beans.

11.What are the key components of persistence API in EJB?

Following are the key components of persistence API in EJB:

  • Entity - A persistent object representing the data-store record. It is good to be serializable.
  • EntityManager - Persistence interface to do data operations like add/delete/update/find on persistent objectentity. It also helps to execute queries using Query interface.
  • Persistence unit persistence. xml - Persistence unit describes the properties of persistence mechanism.
  • Data Source ∗ ds. xml - Data Source describes the data-store related properties like connection url. user-name,password etc.

12.Is Message Driven bean a stateless bean?

Message driven bean is a stateless bean and is used to do task asynchronously.

13.Explain @javax.ejb.Stateless annotation.?

@javax.ejb.Stateless annotation specifies that a given ejb class is a stateless session bean.Following are its attributes:

  • name - Used to specify name of the session bean.
  • mappedName - Used to specify the JNDI name of the session bean.
  • description - Used to provide description of the session bean.

14.Explain @javax.ejb.Stateful annotation.?

@javax.ejb.Stateful annotation specifies that a given ejb class is a stateful session bean.Following are its attributes:

  • bname - Used to specify name of the session bean.
  • bmappedName - Used to specify the JNDI name of the session bean.
  • bdescription - Used to provide description of the session bean.

15.Explain @javax.ejb.MessageDrivenBean annotation.?

@javax.ejb.MessageDrivenBean annotation specifies that a given ejb class is a message driven bean. Following are its attributes: name - Used to specify name of the message driven bean. messageListenerInterface - Used to specify message listener interface for the message driven bean. activationConfig - Used to specify the configuration details of the message-driven bean in operational environment of the message driven bean. mappedName - Used to specify the JNDI name of the message driven bean. description - Used to provide description of the message driven bean.

16.Explain @javax.ejb.EJB annotation.?

@javax.ejb.EJB annotation is used to specify or inject a dependency as ejb instance into another ejb. Following are its attributes:

  • name - Used to specify name which will be used to locate the referenced bean in environment.
  • beanInterface - Used to specify the interface type of the referenced bean.
  • beanName - Used to provide name of the referenced bean.
  • mappedName -Used to specify the JNDI name of the referenced bean.
  • description - Used to provide description of the referenced bean.

17.Explain @javax.ejb.Local annotation.?

@javax.ejb.Local annotation is used to specify Local interfaces of a session bean. This local interface states the business methods of the session bean whichcanbestatelessorstateful.
This interface is used to expose the business methods to local clients which are running in same deployment/application as EJB.

18.Following are its attributes:?

  • value - Used to specify the list of local interfaces as an array of interfaces.

19.Explain @javax.ejb.Remote annotation.?

@javax.ejb.Remote annotation is used to specify Remote interfaces of a session bean. This remote interface states the business methods of the session bean whichcanbestatelessorstateful.
This interface is used to expose the business methods to remote clients which are running in different deployment/application as EJB.

20.Following are its attributes:?

  • value - Used to specify the list of remote interfaces as an array of interfaces.

« Previous | 0 | 1 | 2 | 3 | 4 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com