• +91 9723535972
  • info@interviewmaterial.com

EJB Interview Questions and Answers

EJB Interview Questions and Answers

Question - 51 : - How many EJB Objects are created for a Bean?

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

Question - 52 : - What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

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

Question - 53 : - What is the difference between EAR, JAR and WAR file?

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

Question - 54 : - What is lazy loading?

Answer - 54 : - Lazy loading means not creating an object until the first time it is accessed. Lazy loading typically looks like this: public class Example { private Vector data = null; public Vector getData() { if (this.data == null) { this.data = new Vector(); // Load data into vector … } return this.data; } } This technique is most useful when you have large hierarchies of objects (such as a product catalog). You can lazy-load subordinate objects as you navigate down the hierarchy, and thereby only create objects when you need them.

Question - 55 : - Can i map more than one table in a CMP?

Answer - 55 : - No, you cannot map more than one table to a single CMP Entity Bean. CMP has been, in fact, designed to map a single table.

Question - 56 : - Is Decorator an EJB design pattern?

Answer - 56 : - No. Decorator design pattern, is the one which exhibits very low level runtime polymorphism, for the specific and single object (Instance of the class), but not for atleast for a class. It is the stuff to add specific functionality to a single & pointed object and leaves others like it unmodified. It is having close similarities like aspectJ stuff, but not with EJB stuff.

Question - 57 : - What is the difference between sessioncontext and entitycontext?

Answer - 57 : - Since EnterpriseBeans live in a managed container, the container is free to call  your EJB components methods at its leisure. The container houses the information like current status of bean,security credentials of the user currently accessing the bean in one object is called EJBContext Object. A context represents a way for beans to perform callbacks and modify their current status Sessioncontext is EJB context for session bean Entitycontext is EJB context for entity bean Message driven context is EJB context for message driven bean

Question - 58 : - Does stateless Session bean create() method contain any parameters?

Answer - 58 : - Stateless SessionBean create() method doesnot contain any parameters and the syntax is as follows: public interface XSessionEJBHome extends EJBHome { XSessionEJB create() throws RemoteException, CreateException; }

Question - 59 : - What is difference between EJB 1.1 and EJB 2.0?

Answer - 59 : - The bulk of the changes in EJB 2.0 are found in the definition of a new CMP component model. It’s radically different from the old CMP model because it introduces an entirely new participant, the persistence manager, and a completely new way of defining container-managed fields, as well as relationships with other beans and dependent objects.

Question - 60 : - Can a Session Bean be defined without ejbCreate() method?

Answer - 60 : - The ejbCreate() methods is part of the bean’s lifecycle, so, the compiler will not return an error because there is no ejbCreate() method. However, the J2EE spec is explicit: · the home interface of a Stateless Session Bean must have a single create() method with no arguments, while the session bean class must contain exactly one ejbCreate() method, also without arguments. · Stateful Session Beans can have arguments (more than one create method)


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners