EJB Interview Questions & Answers

Showing 10 of 54 questions | Page 5

Technical interview questions and answers are crucial for clearing an EJB Interview because Enterprise JavaBeans are widely used in enterprise-level, distributed, and transactional applications. Companies evaluate your understanding of session beans, entity beans, message-driven beans, JNDI, lifecycle methods, and container-managed transactions. These concepts often appear in Java developer interviews conducted by TCS, Wipro, Infosys, Cognizant, and Accenture. For freshers and job seekers planning to enter Java-based development roles, EJB forms an important part of backend and enterprise Java interviews. This guide provides the most frequently asked EJB interview questions with answers, explained in simple language to help you understand real-time use cases. Preparing these questions will help you succeed in technical rounds and placement tests focused on Java EE technologies.

Java developers should also master J2EE concepts and explore J2SE fundamentals  for comprehensive enterprise development expertise 

Showing 10 of 54 questions

41. Is Decorator an EJB design pattern?

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.

42. What is the difference between sessioncontext and entitycontext?

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

43. Does stateless Session bean create() method contain any parameters?

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

44. What is difference between EJB 1.1 and EJB 2.0?

The bulk of the changes in EJB 2.0 are found in the definition of a new CMP component model. Its 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.

45. What is the difference between ejbCreate() and ejbPostCreate

The purpose of ejbPostCreate() is to perform clean-up database operations after SQL INSERTs (which occur when ejbCreate() is called) when working with CMP entity beans. ejbCreate() is called before database INSERT operations. You need to use ejbPostCreate() to define operations, like set a flag, after INSERT completes successfully.

46. Why does EJB needs two interfaces(Home and Remote Interface)

There is a pure division of roles between the two . Home Interface is the way to communicate with the container which is responsible for creating , locating and removing beans and Remote Interface is the link to the bean that allows acces to all methods and members.

47. What are the optional clauses in EJB QL?

WHERE and ORDERBY clauses are optional in EJB QL where as SELECT and FROM are required clauses.

48. Can I invoke Runtime.gc() in an EJB?

You shouldnt. What will happen depends on the implementation, but the call will most likely be ignored.

49. What is Remote client view?

The remote client view specification is only available in EJB 2.0. The remote client view of an enterprise bean is location independent. A client running in the same JVM as a bean instance uses the same API to access the bean as a client running in a different JVM on the same or different machine. Remote interface: The remote interface specifies the remote business methods that a client can call on an enterprise bean. Remote home interface: The remote home interface specifies the methods used

50. What is Local client view?

The local client view specification is only available in EJB 2.0. Unlike the remote client view, the local client view of a bean is location dependent. Local client view access to an enterprise bean requires both the local client and the enterprise bean that provides the local client view to be in the same JVM. The local client view therefore does not provide the location transparency provided by the remote client view. Local interfaces and local home interfaces provide support for lightweight a
Questions and Answers for Competitive Exams Various Entrance Test