TechAlpine – The Technology world

Test your knowledge in Enterprise Java Beans

EJB

Enterprise Java Beans – Do you still remember it?

Introduction: In this article, we have taken an initiative to answer some of the frequently asked questions on EJB. Enterprise Java Beans are used widely for different use cases. It can handle the business logic (Session Beans), database entity (Entity Beans) and also messages (MDB). We have tried to compiled some of the key areas in EJB and answer the questions. This is the first series on EJB. We will publish some more series in the coming days. Hope it will help you a lot.








1: What is EJB container?

Answer: An EJB container can be defined as a program that runs on the application server and implements the EJB specifications.

2: What is application server?

Answer: An application server can be defined as an application program that provides an environment to run enterprise applications.

3: Why application server is popular for enterprise application development?

Answer: Application servers provide all environmental supports like transaction, security, persistence etc. readily to an enterprise application. So the enterprise application development is much easier while application server is used for implementation.

4: Name two popular application servers used nowadays?

Answer: Weblogic and websphere application server.

5: Where does an application server run?

Answer: Application server can run both remotely and on the client machine itself.

6: What is the difference between application server and EJB server?

Answer: Application server provides supports for an enterprise application and EJB server provides supports for enterprise beans only.

7: What is an enterprise bean?

Answer: Enterprise beans are basically designed to encapsulate the business logic of an enterprise application. It is a Java EE server side component and runs inside EJB container.

8: When do you use enterprise bean?

Answer: Enterprise beans are used for large scale enterprise application development. So if an enterprise application requires transaction, integrity, scalability etc. then enterprise beans are the best fit.
9: What are the types of beans available in EJB3.0?

Answer: In EJB3.0 there are two types of enterprise beans available
1) Session bean
2) Message driven bean

10: What interfaces are eliminated in EJB3.0?

Answer: Home and remote interfaces are eliminated in EJB3.0 version.

11: On what model EJB3.0 has been developed?

Answer: EJB3.0 has been developed based on plain old java object (POJO) programming model.

12: What is known as business logic layer in EJB?

Answer: Session beans and message-driven beans together constitute the business logic layer in EJB.

13: What is persistence layer?

Answer: This is the layer responsible for persisting the application data in a relational database. Entity beans are used in this layer.

14: What are the negative sides of EJB2.x specification?

Answer: Following are some negative sides of EJB2.x specification
a) Component interface needs to implement interfaces from EJB framework package. So the components are tightly coupled.
b) EJB deployment descriptors are very complex and error prone.
c) Testing of components is hard.
d) Persistence model is not well defined.

15: Describe some features of EJB3.0 model.

Answer: Following are some important features introduced in EJB3.0 model
a) Entity beans are replaced by POJO.
b) Deployment descriptor information is replaced by annotations
c) JPA is used for persistence model








16: What types of annotations are used in EJB3.0 specification?

Answer: Metadata based annotations are used by EJB3.0 specification.

17: How do you define a POJO class as an EJB component?

Answer: By using special type of annotations a POJO class can be defined as an EJB component.

18: What are the types of session beans available in EJB3.0?

Answer: There are two types of session beans a) stateful and b) stateless.

19: When do you use a stateless session bean?

Answer: A stateless session bean is used when the conversational state is not required to maintain.

20: What are the components defined in EJB2.x stateless session bean?

Answer: There are three main components
a) EJB component interface
b) EJB home interface
c) EJB bean class

21: What annotation is used to indicate a stateless session bean?

Answer: @Stateless annotation is used to define a stateless session bean.

22: What is the function of the annotation?

Answer: The annotation tells the container that the POJO is session bean and enforces the life cycle and runtime semantics.

23: What annotation is used to indicate a remote interface implementation?

Answer: The ‘@Remote’ annotation is used to refer a remote interface.

24: When do you use a stateful session bean?

Answer: A stateful session bean is used when the state of a business process needs to be retained.
25: What annotation is used to indicate a stateless session bean?

Answer: The ‘@Stateful’ annotation is used to indicate a stateless session bean.







26: Can a session be abstract or final POJO?

Answer: The session bean must be a concrete POJO.

27: Can a session EJB subclass another session EJB?

Answer: No, a session EJB cannot subclass another session EJB. It can only sub class a POJO.

28: Why a message driven bean is used?

Answer: Message driven beans are used to process asynchronous messages within a J2EE based application.

29: Who is responsible for invoking a message driven bean?

Answer: Message driven beans are invoked by the container. They are never invoked by a client or another bean.

30: What annotation is used for a message driven bean?

Answer: The ‘@MessageDriven’ annotation is used for a message driven bean.

31: What is the name of the interface implemented by a message driven bean?

Answer: The ‘MessageListener’ interface is implemented by message driven bean. And there is only one method defined inside it known as ‘onMessage’.

32: What is the name of the property used in message driven bean for configuration related information?

Answer: The name is ‘ActivationConfigProperty’. It contains all configuration information.

33: What is the impact of annotations on call back methods?

Answer: Annotations are used to mark call back methods which are required for life cycle management.

34: Are the life cycle methods mandatory in EJB 3.0 specification?

Answer: No, implementation of life cycle methods are optional in EJB 3.0 specification. But they are mandatory in EJB 2.x specification even if you do not use it.

35: Describe the life cycle of a stateful session bean.

Answer: Following are the life cycle stages of a stateful session bean
a) Create
b) Dependency injection
c) PostConstruct call back
d) Remove
e) PreDestruct call back








Please follow and like us:
0

Leave a Reply

Your email address will not be published. Required fields are marked *


− 6 = 2

============================================= ============================================== Buy TechAlpine Books on Amazon
============================================== ----------------------------------------------------------------

Enjoy this blog? Please spread the word :)

Follow by Email
Facebook
Facebook
Google+
http://techalpine.com/test-your-knowledge-in-enterprise-java-beans">
LinkedIn