- 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: 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: 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 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 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:
Question: What is the difference between JNDI context, Initial context, session context and ejb context?

Answer: JNDI Context Provides a mechanism to lookup resources on the network
Initial Context constructor provides the initial context.
Session Context has all the information a session bean would require from the container
Entity Context has all the information that an Entity bean would need from a container
Ejb Context contains the information that is common to both the session and entity bean Source:
Question: Can I develop an Entity Bean without implementing the create() method in the home interface?

Answer: As per the specifications, there can be 'ZERO' or 'MORE' create() methods defined in an Entity Bean. In cases where create() method is not provided, the only way to access the bean is by knowing its primary key, and by acquiring a handle to it by using its corresponding finder method.

Submitted by: Daksh Source:
Question: What are the various isolation levels in a transaction and differences between them?

Answer: There are three isolation levels in Transaction. They are 1. Dirty reads 2.Non repeatable reads 3. Phantom reads.

Dirrty Reads If transaction A updates a record in database followed by the transaction B reading the record then the transaction A performs a rollback on its update operation, the result that transaction B had read is invalid as it has been rolled back by transaction A.

NonRepeatable ReadsIf transaction A reads a record, followed by transaction B updating the same r Source:
Question: What is the difference between normal Java object and EJB?

Answer: Java Object: is a reusable component.
EJB : is a distributed component used to develop business applications. Container provides runtime environment for EJBs.
Question: What is the difference between activation and passivation?

Answer: This would be the difference between Activation and Passivation:

While the bean is in the ready stage, the EJB container may decide to deactivate, or passivate, the bean by moving it from memory to secondary storage. (Typically, the EJB container uses a least-recently-used algorithm to select a bean for passivation.) The EJB container invokes the bean's ejbPassivate method immediately before passivating it. If a client invokes a business method on the bean while it is in the passive s 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: When you will chose Stateful session bean and Stateless session bean?

Answer: Stateful session beans are used when there is converstional state and when there is a need of temporary storage

Stateless session bean are used when there is no conversational state and when session bean has to be used only for database access 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: What is the difference between JavaBean and EJB?

Answer: A Java Bean is a software component written in the Java programming language that conforms to the JavaBeans component specification. The JavaBeans APIs became part of the "core" Java APIs as of the 1.1 release of the JDK.

The JavaBeans specification defines a Java-based software component model that adds a number of features to the Java programming language. Some of these features include:

* introspection
* customization
* events
* properties
* persi 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: 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: How will you propagate exception thrown inside session bean to JSP or Servlet client?

Answer: 2 types of exceptions can occur

1.System Exception - We can define some error codes the in the property file and show it to the JSP
2.Application Exception.. - We can customise the exception and show the appropriate error
Question: What is the difference between HTTPSession and Stateful Session Bean?

Answer: From a logical point of view, a Servlet/JSP session is similar to an EJB session. Using a session, in fact, a client can connect to a server and maintain his state.

But, is important to understand, that the session is maintained in different ways and, in theory, for different scopes.

A session in a Servlet, is maintained by the Servlet Container through the HttpSession object, that is acquired through the request object. You cannot really instantiate a new HttpSession object, a 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:

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.40625 Seconds