Java Ejb 3.0 Interview Questions and Answers for Experienced - 1

Question: 1

What is EJB?

EJB is a standard for building server side components in JAVA. It specifies an agreement between components and application servers that enables any component to run in any application server.

EJP components are deployable and can be imported in to an application server which hosts these components.

EJB are not intended for client side they are server side components.

They are specially meant for complex server side components like executing complex algorithms or high volume business transactions.

Question: 2

What are the different kind of EJB’s?

There are three kinds of EJB’s

Session beans

Session beans are construct in EJB. They represent business logic of an application. They represent a group of logical related functioanality.

There are two types of session beans:

Stateless: They do not maintain state across method calls. So every time client makes a call its like a new object from scratch.

Stateful: These beans can hold client state across method invocations. This is possible with the use of instance variables declared in the class definition. Every time the client calls it they can get there previous states.

Stateless session bean provide greater scalability as EJB container does not have to maintain state across method invocations. Storing state for EJB container is huge activity.

Entity beans:

Entity bean represent persistent data in an EJB application. They provide object oriented abstraction to a relational database. When session bean needs to access data it calls the entity beans. Entity beans do read, write, update and delete from tables.

Message driven beans:

There are situations in project where you would like to communicate asynchronously with some other systems. This is achieved by using message driven beans.

Question: 3

Can beans who are involved in transaction have passivation process?


Question: 4

Which application server have you used for EJB?

JBOSS as the application server to host EJB components.

Question: 5

What are the limitations of using Local object?

Local object only work if you are calling beans in the same process. Second they marshal data by ref rather than by val.

This may speed up your performance but you need to change semantics for the same.

So finally it’s a design and the requirements decision. If you are expecting to call beans remotely then using local object will not work.

Related Questions