• +91 9723535972
  • info@interviewmaterial.com

EJB Interview Questions and Answers

EJB Interview Questions and Answers

Question - 41 : - Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Answer - 41 : - You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as passed-by-value, that means that it’s read-only in the EJB. If anything is altered from inside the EJB, it won’t be reflected back to the HttpSession of the Servlet Container.The pass-by-reference can be used between EJBs Remote Interfaces, as they are remote references. While it is possible to pass an HttpSession as a parameter to an EJB object, it is considered to be bad practice in terms of object-oriented design. This is because you are creating an unnecessary coupling between back-end objects (EJBs) and front-end objects (HttpSession). Create a higher-level of abstraction for your EJBs API. Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end. Consider the case where your EJB needs to support a non HTTP-based client. This higher level of abstraction will be flexible enough to support it.

Question - 42 : - How does a servlet communicate with a JSP page?

Answer - 42 : - The following code snippet shows how a servlet instantiates a bean and initializes it with FORM data posted by a browser. The bean is then placed into the request, and the call is then forwarded to the JSP page, Bean1.jsp, by means of a request dispatcher for downstream processing.

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

Answer - 43 : - 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 - 44 : - What is the difference between JavaBean and EJB?

Answer - 44 : - 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 - 45 : - What is abstract schema?

Answer - 45 : - 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 - 46 : - What is Message Driven Bean?

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

Question - 47 : - What are the call back methods in Entity bean?

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

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

Answer - 48 : - 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 - 49 : - What are the services provided by container?

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

Question - 50 : - What is deployment descriptor?

Answer - 50 : - Deployment descriptor is a XML file. which is used to locate the web applicatio n by container.it includes the details of respective bean.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners