![EJB Tutorial](/ejb/images/ejb-mini-logo.jpg)
- EJB Tutorial
- EJB - Home
- EJB - Overview
- EJB - Environment Setup
- EJB - Create Application
- EJB - Stateless Bean
- EJB - Stateful Bean
- EJB - Persistence
- EJB - Message Driven Beans
- EJB - Annotations
- EJB - Callbacks
- EJB - Timer Service
- EJB - Dependency Injection
- EJB - Interceptors
- EJB - Embeddable Objects
- EJB - Blobs/Clobs
- EJB - Transactions
- EJB - Security
- EJB - JNDI Bindings
- EJB - Entity Relationships
- EJB - Access Database
- EJB - Query Language
- EJB - Exception Handling
- EJB - Web Services
- EJB - Packaging Applications
- EJB Useful Resources
- EJB - Quick Guide
- EJB - Useful Resources
- EJB - Discussion
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.
![Questions and Answers](/images/questions_and_answers.png)
Q 1 - Which of the following is true about message driven bean?
A - This type of bean stores data of a particular user for a single session.
Answer : B
Explaination
A message driven bean is a type of enterprise bean which is invoked by EJB container when it receives a message from queue or topic. Message driven bean is a stateless bean and is used to do task asynchronously.
Q 2 - Which of the following is correct about Entity 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 : A
Explaination
Entity is a persistent object representing the data-store record. It is good to be serializable.
Q 3 - Which of the following is correct about activationConfig attribute in @javax.ejb.MessageDrivenBean annotation?
A - It is used to specify name of the message driven bean.
B - it is used to specify message listener interface for the message driven bean.
D - It is used to specify the JNDI name of the message driven bean.
Answer : C
Explaination
activationConfig attribute in @javax.ejb.MessageDrivenBean annotation is used to specify the configuration details of the message-driven bean in operational environment of the message driven bean.
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 - @javax.ejb.Local annotation is used to specify Local interface(s) of a session bean.
Answer : A
Explaination
@javax.ejb.Local annotation is used to specify Local interface(s) of a session bean.
Q 6 - Which of the following is correct about @PrePassivate annotation for a callback method?
A - Method is invoked when a bean is created for the first time.
B - Method is invoked when a bean is removed from the bean pool or is destroyed.
Answer : D
Explaination
@PrePassivate - method is invoked when a bean is put back to bean pool.
Q 7 - Which annotation is used to inject singleton services like timer service into an ejb?
Answer : B
Explaination
@Resource annotation is used to inject singleton services like timer service into an ejb.
Q 8 - Which of the following is correct about a Consistent transaction in EJB?
B - A transaction must keep the system in consistent state.
C - Each transaction executes independent of any other transaction.
D - Transaction should survive system failure if it has been executed or committed.
Answer : B
Explaination
Consistent - A transaction must keep the system in consistent state.
Q 9 - Which of the following is correct about a REQUIRES_NEW attrribute of Container Managed Transactions in EJB?
B - Indicates that a new transaction is to be started for the business method.
C - Indicates that business method will execute as part of transaction.
D - Indicates that business method should not be executed as part of transaction.
Answer : B
Explaination
REQUIRES_NEW - Indicates that a new transaction is to be started for the business method.
Q 10 - Which of the following is true about Application level exception in EJB?
Answer : A
Explaination
If business rule is voilated or exception occurs while executing the business logic will be treated as application level exception.