• +91 9971497814
  • info@interviewmaterial.com

EJB Interview Questions Answers

Question 1 : What are transaction isolation levels in EJB?

Answer 1 : 1. Transaction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise). 2. Transaction_read_committed- Guarantees that the data you are getting has been committed. 3. Transaction_repeatable_read - Guarantees that all reads of the database will be the same during the transaction (good for read and update operations). 4. Transaction_serializable- All the transactions for resource are performed serial.

Question 2 : What is the difference between a Coarse Grained Entity Bean and a Fine Grained Entity Bean?

Answer 2 : A ‘fine grained’ entity bean is directly mapped to one relational table, in third normal form. A ‘coarse grained’ entity bean is larger and more complex, either because its attributes include values or lists from other tables, or because it ‘owns’ one or more sets of dependent objects. Note that the coarse grained bean might be mapped to a single table or flat file, but that single table is going to be pretty ugly, with data copied from other tables, repeated field groups, columns that are dependent on non-key fields, etc. Fine grained entities are generally considered a liability in large systems because they will tend to increase the load on several of the EJB server’s subsystems (there will be more objects exported through the distribution layer, more objects participating in transactions, more skeletons in memory, more EJB Objects in memory, etc.)

Question 3 : What is the difference between JavaBean and EJB?

Answer 3 : 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.

Question 4 : What is the difference between find and select methods in EJB?

Answer 4 : A select method can return a persistent field (or a collection thereof) of a related entity bean. A finder method can return only a local or remote interface (or a collection of interfaces). Because it is not exposed in any of the local or remote interfaces, a select method cannot be invoked by a client. It can be invoked only by the methods implemented within the entity bean class. A select method is usually invoked by either a business or a home method. A select method is defined in the entity bean class. For bean-managed persistence, a finder method is defined in the entity bean class, but for container-managed persistence it is not.

Question 5 : What is a Server Group?

Answer 5 : A server group is a template of an Application Server(and its contents) i.e, it is a logical representation of the application server. It has the same structure and attributes as the real Application Server, but it is not associated with any node, and does not correspond to any real server process running on any node.

Question 6 : What is Session Bean?

Answer 6 : A session bean is a non-persistent object that implements some business logic running on the server. One way to think of a session object is as a logical extension of the client program that runs on the server. Session beans are used to manage the interactions of entity and other session beans,access resources, and generally perform tasks on behalf of the client. There are two basic kinds of session bean: stateless and stateful. Stateless session beans are made up of business methods that behave like procedures; they operate only on the arguments passed to them when they are invoked. Stateless beans are called stateless because they are transient; they do not maintain business state between method invocations.Each invocation of a stateless business method is independent from previous invocations. Because stateless session beans are stateless, they are easier for the EJB container to manage, so they tend to process requests faster and use less resources. Stateful session beans encapsulate business logic and state specific to a client. Stateful beans are called “stateful” because they do maintain business state between method invocations, held in memory and not persistent. Unlike stateless session beans, clients do not share stateful beans. When a client creates a stateful bean, that bean instance is dedicated to service only that client. This makes it possible to maintain conversational state, which is business state that can be shared by methods in the same stateful bean.

Question 7 : What is abstract schema?

Answer 7 : 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.

Question 8 : Is it legal to have static initializer blocks in EJB?

Answer 8 : Although technically it is legal, static initializer blocks are used to execute some piece of code before executing any constructor or method while instantiating a class. Static initializer blocks are also typically used to initialize static fields - which may be illegal in EJB if they are read/write - In EJB this can be achieved by including the code in either the ejbCreate(), setSessionContext() or setEntityContext() methods

Question 9 : What is local interface. How values will be passed?

Answer 9 : 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.

Question 10 : What is EJB client JAR file?

Answer 10 : An EJB client JAR file is an optional JAR file that can contain all the class files that a client program needs to use the client view of the enterprise beans that are contained in the EJB JAR file. If you decide not to create a client JAR file for an EJB module, all of the client interface classes will be in the EJB JAR file.

EJB Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners