- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
EJB Interview Questions & Answers - Learning Mode

EJB Interview Questions & Answers - Learning Mode

Enterprise Java Beans (EJB) is a development architecture for building highly scalable and robust enterprise level applications to be deployed on J2EE compliant Application Server such as JBOSS, Web Logic etc. Enterprise JavaBeans (EJB) is an architecture for setting up program components, written in the Java programming language, that run in the server parts of a computer network that uses the client/server model.

Try EJB Interview Questions & Answers - Exam Mode

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Next

Sort By : Latest First | Oldest First | By Rating

EJB Interview Questions & Answers - Learning Mode
Try EJB Interview Questions & Answers - Exam Mode
Question: What is EJB architecture(components)?

Answer: Enterprise beans

An enterprise bean is a non-visual component of a distributed, transaction-oriented enterprise application. Enterprise beans are typically deployed in EJB containers and run on EJB servers.

There are three types of enterprise beans: session beans, entity beans, and message-driven beans.

Session beans: Session beans are non-persistent enterprise beans. They can be stateful or stateless. A stateful session bean acts on behalf of a single client and maintains c Source:
Question: What is the difference between ejbCreate() and ejbPostCreate

Answer: The purpose of ejbPostCreate() is to perform clean-up database operations after SQL INSERTs (which occur when ejbCreate() is called) when working with CMP entity beans. ejbCreate() is called before database INSERT operations. You need to use ejbPostCreate() to define operations, like set a flag, after INSERT completes successfully.

When working with BMP entity beans, this is not necessary. You have full control over the entire process, so you can place all the necessary logic surrounding Source:
Question: Is there a way to get the original exception object from inside a nested or wrapped Exception (for example an EJBException or RemoteException)

Answer: Yes.
The way to get, depends on the Exception, since there are no standards. Some examples:

* When we have an javax.ejb.EJBException, we can use the getCausedByException() that returns a java.lang.Exception.

* A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable

* With a java.sql.SQLException we need to use the method getNextException() to get the chained java.sql.SQLException.

* When we have an java.lang.refl Source:
Question: Does WebLogic support auto generating primary keys for entity beans?

Answer: Yes, this feature was added in WLS 6.1. For more information, see the DTD comments for the <automatic-key-generation> element.
Question: I have 2 session beans sb1 & sb2. In session bean 2 there is a bussiness exception occurs. If I don't want to rollback the transaction in sb1 which declartive transaction attribute I have to use in both beans?

Answer: SB2's transaction attribute should be either "Requires New" or "Not Supported". SB1 can be run in any transaction. It doesn't matter.
Question: Can I invoke Runtime.gc() in an EJB?

Answer: You shouldn't. What will happen depends on the implementation, but the call will most likely be ignored. Source:
Question: If i throw a custom ApplicationException from a business method in Entity bean which is participating

Answer: For declarative transactions, container will rollback on systemException. Container has no way to know whether a speicific application exception is serious enough to roll back the participated transaction. Use setRollbackOnly() to doom the transaction. Source:
Question: Why an onMessage call in Message-driven bean is always a seperate transaction?

Answer: EJB 2.0 specification: "An onMessage call is always a separate transaction, because there is never a transaction in progress when the method is called."

When a message arrives, it is passed to the Message Driven Bean through the onMessage() method, that is where the business logic goes.

Since there is no guarantee when the method is called and when the message will be processed, is the container that is responsible of managing the environment, including transactions ?

Hence Source:
Question: What is the life cycle of Stateless session bean?

Answer: The stateless session bean's life cycle has two states: the Does Not Exist state and the Method-Ready Pool. The Method-Ready Pool is similar to the instance pool used for entity beans. This is one of the significant life-cycle differences between stateless and stateful session beans; stateless beans define instance pooling in their life cycle and stateful beans do not.

Visit for more details on this topic. Source:
Question: What are the key benefits of the EJB technology?

Answer: ► Rapid application development
► Broad industry adoption
► Application portability
► Protection of IT investment Source:
Question: What is the life cycle of MDB

Answer: The lifetime of an MDB instance is controlled by the container. Only two states exist: Does not exist and Ready , as illustrated in the following figure:

The life of an MDB instance starts when the container invokes newInstance() on the MDB class to create a new instance. Next, the container calls setMessageDrivenContext() followed by ejbCreate() on the instance. The bean then enters the Ready state and is ready to consume messages.

When a message arrives for the be Source:
Question: What are the call back methods in Entity bean?

Answer: 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.

Submitted by Prathima Donapudi ( Source:
Question: What is return type of create method of an entity bean

Answer: For CMP Bean, it return NULL and BMP Entity bean, it returns Primary Key Class Object. Source:
Question: What is the use of activate, passivate methods in EJB?

Answer: Ejb activate() and passivate() methods are playing good role in ejbs.

ejb activate() is the method that donotes the objects which are at active state and at the same time passivate() tells us that objects which are at passive state(at sleeping condition).That means if we take an example like bottle.

If there are 10 bottels are in the box which currently using and means they are active and if u want to fill ane more bottle into that box then we should kept that bottle at another Source:
Question: Which are features in EJB 2.0 ? and which are features in EJB 3.0?

Answer: POJO - Plain old Java Objects..

Look for article on EJB3.0 on javaworld

1) EJB2.0 has Deployment descriptors but in EJB3.0 has no Deployment Descriptors.

2) EJB2.0 we have to write Home and Remote Interfaces But in EJB3.0 No need to write Home and remote interfaces.

3) In EJB3.0 We r identifying all entities with '@' symbol.

Deven Mehta USA accentue Source:
Question: What is Instance pooling?

Answer: For SingleThreadModel servlets, containers may follow one of the following approaches to ensure that each sevlet instance is invoked in a separate thread:

Instance Pooling :
in this approach, the container maintains a pool of servlet instances. For each incoming request, the container allocates a servlet instance from the pool, and upon completion of the service, the container returns the instance to the pool.

Request Serialization :
in this approach, the container maintain Source:
Question: The EJB container implements the EJBHome and EJBObject classes. For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes?

Answer: The EJB container maintains an instance pool. The container uses these instances for the EJB Home reference irrespective of the client request. while referring the EJB Object classes the container creates a separate instance for each client request. The instance pool maintenance is up to the implementation of the container. If the container provides one, it is available otherwise it is not mandatory for the provider to implement it. Having said that, yes most of the container providers implement Source:
Question: What is requestdespatcher?

Answer: It is a method that gives object to which next request ,response objects need to be handled to serve the left over work. Source:
Question: What is the difference between ejbStore() and ejbLoad()?

Answer: ejbStore() will be called before ejbPassivate() and is used to store the object to persistent database.

ejbLoad() will be called before ejbActivate() and is used to retrieve the object from persistence datastore.

Submitted by Balasubramanyam Duvvuri ( balasubramanyam.duvvuri @ wipro . com ) Source:
Question: What is deployment descriptor?

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

Submitted by Devarathnam.C ( Source:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.046875 Seconds