- 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: 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: 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: How do you check whether the session is active in Stateful session bean

Answer: In Stateful session bean session is not itself a separate entity. it is contained in the bean it self. So in order to check tht we need the check whether the Stateful session bean is present or not which is done by just invoking the home interface with the jndi 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: 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: 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 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 is the difference between EJB and RMI

Answer: Both of them are java solution for distributed computing.

RMI offers remote access to an object running in another JVM and no other services.

But EJB offers far more services than RMI apart from remote method calling. EJB leverages this remote-object feature of RMI and ORB (RMI-IIOP) which can be called by any COBRA client, but also provides other services such as persistence, transaction management, security, resource management, object pooling and messaging. 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: 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 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: What is meant by Serialization and Externalization? Serialization is a Marker interface,so what is the use of WriteObject() anf ReadObject(), Where it is actually used? Give me some real time examples?

Answer: Marker Interface is used by java runtime engine (JVM) to identify the class for special processing.

Sterilization is a process of converting state of an object to stream of bytes that can be sent over network or can be stored in a file or in database to be reconstructed into Object Later when required. Remember EJB spec, all EJB (Session or Entity) implements Serializable interface indirectly, in case of Statefull session bean it can be Passivated or Activated (Persisted by writi Source:
Question: Why CMP beans are abstract classes?

Answer: We have to provide abstract data to object mapping that maps the fields in our bean to a batabase, and abstract methods methods that corelate these fields. 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: Is it possible to share an HttpSession between a JSP and EJB. What happens when I change a value in the HttpSession from inside an EJB?

Answer: You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as “passed-by-value”, that means that it’s read-only in the EJB. If anything is altered from inside the EJB, it won’t be reflected back to the HttpSession of the Servlet Container.The “pass-by-reference” can be used between EJBs Remote Interfaces, as they are remote references. While it IS possible to pass an HttpSession as a parameter to an EJB object, Source:
Question: Can undefined primary keys are possible with Entity beans?If so, what type is defined?

Answer: Yes,undefined primary keys are possible with Entity Beans.The type is defined as java.lang.Object. Source:
Question: What is the difference between CMP 1.1 and CMP 2.0

Answer: CMR
and sub classing of the CMP bean by the container 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:

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