Tuesday 3 February 2015

Technical Round EJB Interview Questions and Answers Part6

51.What is the difference between JavaBean and EJB?
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
.persistence

Enterprise JavaBeans (EJBs) are Java-based software components that are built to comply with Java’s EJB specification and run inside of an EJB container supplied by a J2EE provider. An EJB container provides distributed application functionality such as transaction support, persistence and lifecycle management for the EJBs.

52.What is abstract schema?
Abstract schema is part of an entity bean’s deployment descriptor which defines the bean’s persistent fields and their relationship. Abstract schema is specified for entity beans with container managed persistence. We specify the name of the Abstract schema name in the deployment descriptor. The queries written in EJB QL for the finder methods references this name. The information provided in this Abstract Schema is used by the container for persistence management and relationship management.

53.What is local interface. How values will be passed?
An EJB can use local client view only if it is really guaranteed that other enterprise beans or clients will only address the bean within a single JVM. With local client view, you can do pass-by-reference, which means your bean, as well as the client, will work directly with one copy of the data. Any changes made by the bean will be seen by the client and vice versa. Pass-by-reference eliminates time/system expenses for copying data variables, which provides a performance advantage.

54.What is Message Driven Bean?
An MDB is essentially a message consumer that can listen to a message destination or a message endpoint and gets activated when a message arrives. By design, MDBs are anonymous in nature and hence cannot be directly invoked by a client. The only way to invoke an MDB is to send a message to the destination or endpoint to which it is listening. As MDBs are stateless in nature and are not related to any specific client, they can be pooled for concurrent processing of messages.

55.What are the call back methods in Entity bean?
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.

56.What are the services provided by container?
Container services are totally depends upon the “vendor implementation”. But more or less most of the vendors suppots the basic services like,
LifeCycle Management - It is Automatic.
Session Management - it is used by Developer coded callback methods…
Transaction Management - it is used by configuring deployment descriptor (DD) .
Security management - it is used by configuring deployment descriptor (DD) .
The other services, if any will be in advanced versions, and depends on Vendor specific.

57.What is deployment descriptor?
Deployment descriptor is a XML file. which is used to locate the web applicatio n by container.it includes the details of respective bean.

58.How many EJB Objects are created for a Bean?
For a Session bean - one EJB object for one bean instance.
For entity bean - it depends , if 2 users are accessing one row at time then one EJB object is used for both the beans other wise for each bean one EJB object.

59.What is re-entrant. Is session beans reentrant. Is entity beans reentrant?
If we define the entity bean as being reentrant, multiple clients can connect to the Entity bean & execute methods within the entity bean concurrently. Container takes care of synchronization. If we define the entity bean as non-reentrant and many clients connect to it concurrently to execute a method, exception is thrown .

60.What is the difference between EAR, JAR and WAR file?
J2EE defines three types of archives:
1. Java Archives (JAR) A JAR file encapsulates one or more Java classes, a manifest, and a descriptor. JAR files are the lowest level of archive. JAR files are used in J2EE for packaging EJBs and client-side Java Applications.
2. Web Archives (WAR) WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes.
3. Enterprise Archives (EAR) ”An EAR file contains all of the components that make up a particular J2EE application.
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5  Part6  Part7  Part8

No comments:

Post a Comment