EJB Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to EJB Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - Which of the following is true about session bean?
A - This type of bean stores data of a particular user for a single session.
Answer : A
Explaination
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.
Q 2 - Which of the following bean stores data of a particular user for a single session?
Answer : A
Explaination
Session bean stores data of a particular user for a single session.
Q 3 - Which of the following is correct about EntityManager in EJB persistence API?
A - It is a persistent object representing the data-store record. It is good to be serializable.
C - It describes the properties of persistence mechanism.
D - It describes the data-store related properties like connection url. user-name,password etc.
Answer : B
Explaination
EntityManager is an interface to do data operations like add/delete/update/find on persistent object. It also helps to execute queries using Query interface.
Q 4 - Which of the following annotation is used to specify that a given ejb class is a stateless session bean?
Answer : A
Explaination
@javax.ejb.Stateless annotation specifies that a given ejb class is a stateless session bean.
Q 5 - Which of the following annotation is used to specify callback method of ejb lifecycle?
Answer : A
Explaination
@javax.ejb.PostActivate annotation is used to specify callback method of ejb lifecycle.
Q 6 - Which of the following is true about callbacks in EJB?
A - Callback is a mechanism by which life cycle of an enterprise bean can be intercepted.
B - EJB Container calls callbacks.
C - We can define callback methods in the ejb class itself or in a separate class.
Answer : D
Explaination
Callback is a mechanism by which life cycle of an enterprise bean can be intercepted. EJB 3.0 specification has specified callbacks for which callback handler methods are to be created. EJB Container calls these callbacks. We can define callback methods in the ejb class itself or in a separate class. EJB 3.0 has provided many annotations for callbacks.
Q 7 - Which of the following is correct about Class level interceptor in EJB?
A - Such interceptor is invoked for every method of the bean.
B - Such interceptor is invoked for every bean within deployment.
C - Such interceptor is invoked for a particular method of the bean.
Answer : A
Explaination
Class level interceptor is invoked for every method of the bean.
Q 8 - Which of the following is correct about a transaction in EJB?
A - A transaction is a single unit of work items.
Answer : C
Explaination
A transaction is a single unit of work items which follows the ACID properties.
Q 9 - Which of the following is correct about a DeclareRoles attrribute of Container Managed Transactions in EJB?
A - Indicates that class will accept those declared roles. Annotations are applied at class level.
Answer : A
Explaination
DeclareRoles - Indicates that class will accept those declared roles. Annotations are applied at class level.
Q 10 - Which of the following is true about exceptions handling by EJB Container?
Answer : C
Explaination
When Application Exception occurs, ejb container intercepts the exception but returns the same to the client as it is. It does not roll back the transaction unless it is specified in code by EJBContext.setRollBackOnly() method.