Labels

.NET Job Questions About Java Absract class Abstract class Abstract Class and Interface Aggregation ajax aop apache ofbiz Apache ofbiz tutrial Association authentication autocad basics batch Binary Tree bootstrap loader in java build Builder design pattern C++ Job Questions caching CallableStatement in java certifications Chain of responsibility Design pattern charts check parentheses in a string Classes classloader in java classloading concept code quality collage level java program Composition concurrency Concurrency Tutorial Converting InputStream to String Core Java core java concept core java interview questions Core Java Interview Questions Core Java Questions core java tutorial CyclicBarrier in Java data structures database Database Job Questions datetime in c# DB Db2 SQL Replication deserialization in java Design Patterns designpatterns Downloads dtd Eclipse ejb example/sample code exception handling in core java file handling injava File I/O vs Memory-Mapped Filter first program in spring flex Garbage Collection Generics concept in java grails groovy and grails Guice Heap hibernate Hibernate Interview Questions how-to IBM DB2 IBM DB2 Tutorial ide immutable Interceptor Interface interview Interview Questions for Advanced JAVA investment bank j2ee java JAVA Code Examples Java 7 java changes java class loading JAVA Classes and Objects Java Classloader concept Java classloading concept java cloning concept java collection Java collection interview questions Java Collections java concurrency Java CountDownLatch java definiton Java design pattern Java EE 5 Java EE 6 Java Exceptions Java file Java Garbage Collection Java generics Java Glossary java hot concept java immutable concept Java Interface Java interview Question java interview question 2012 java interview question answer Java Interview Questions Java Interview Questions and Answers java interview topic java investment bank Java Job Questions java multithreading java multithreading concept java new features Java Packages java proxy object java questions Java Serialization Java serialization concept java serialization interview question java session concept java string Java Swings Questions java synchronization java threading Java Threads Questions java tutorial java util; java collections; java questions java volatile java volatile interview question Java Wrapper Classes java.java1.5 java.lang.ClassCastException JavaNotes javascript JAX-WS jdbc JDBC JDBC Database connection jdk 1.5 features JDK 1.5 new features Concurrent HashMap JMS interview question JMS tutorial job JSESSIONID concept JSESSIONID interview Question JSF jsp JSP Interview Question JSP taglib JSTL with JSP Junit Junit Concept Junit interview question.Best Practices to write JUnit test cases in Java JVM Linux - Unix tutorial Marker Interfaces MD5 encryption and decryption messaging MNC software java interview question musix NCR java interview question Networking Job Questions news Object Serialization Objects ojdbc14.jar OOP Oracle Oracle SQL Query for two timestamp difference orm own JavaScript function call in Apache ofbiz Packages Palm Apps patterns pdf persistence Portal Portlet Spring Integration Prime number test in java programs Rails Reboot remote computers REST Ruby Sample application schema SCJP security Senior java developer interviews servlet3 servlets session tracking singleton design pattern Spring Spring 2.5 Framework spring ebook Spring framework concept spring MVC spring pdf Spring Security Spring Security interview questions SQL SQL performance SQL Query to create xml file Sql Query tuning ssis and ssrs StAX and XML string concept string immutable string in java strings struts Struts2 Struts2 integration synchronization works in java Technical Interview testing tips Tomcat top Tutorial Volatile in deep Volatile working concept web Web Developer Job Questions web services weblogic Weblogic Application Server websphere what is JSESSIONID xml XML parsing in java XML with Java xslt


Monday, 22 July 2013

LNT EJB 2012 solved questions


EJB QnA

Ques.1>What is EJB?
http:\\capptitudebank.blogspot.in
>
Ans.>EJB stands for Enterprise Java Beans and is widely-adopted server side component architecture for J2EE. It enables rapid development of critical application that are versatile, reusable and portable across middleware while protecting IT investment and preventing vendor lock-in. It contains the application's business logic and live business data.

>
Ques.2> What are the different kinds of enterprise beans?

>
Ans.>Different kind of enterprise beans are:
Session bean- It is a non-persistent object that implements some business logic running on the server. They are of two types session bean stateless and stateful.
Entity bean-It is used to represent data in the database. It provides an object-oriented interface.
Message-driven bean- They are enterprise beans that receive and process JMS messages. It doesn’t even have any interface.  

>
Ques.3>What is an EJB Context?

>
Ans.>EJBContext is an interface that is implemented by the container, and is also a part of the bean-container contract. Entity beans use a subclass of EJBContext called EntityContext. Session beans use a subclass called SessionContext. These EJBContext objects fill the bean class with information about its container, the client using the bean and the bean itself. They also provide other functions.

>
Ques.4> How EJB Invocation happens? How can we call one EJB from inside of another EJB?

>
Ans.> It retrieves Home Object reference from Naming Service via JNDI and Return Home Object reference to the client. This is how EJB Invocation happens.
EJBs can be clients of other EJBs. It j works in this way also. JNDI is used to locate the Home Interface of the other bean, and then instance references are acquire and so forth.

>
Ques.5>What is an EJB object?

>
Ans.> EJB objects are used to access the Business logic methods defined by the
user in the bean. It is created by the container when create() method is called by the Home interface. Client gets the reference of the object using JNDI, and their request invokes the business method on bean via the EJB object. The object implements Component Interface.

>
Ques.6> How can we integrate EJB and hibernate? How can we call hibernate DAO methods in session bean?

>
Ans.>Hibernate is used to perform OR (object relational) mapping. it is alternate to DAO.servlets--->ejbSEssionbean(to store businesslogic)--->ejb entity bean(to maintain persistence logic)here we use hibernate instead of entity bean. This integration procedure separates business logic from persistence logic.
To call DAO we use callback methods ejbcreate(), ejbload() to clear previous
datas in database,ejbstore()to store new datas using primary key value.

>
Ques.7> What is bean managed transaction?

>
Ans.> If a developer doesn’t want a Container to manage transactions, it’s possible to implement all database operations manually by writing the appropriate JDBC code. This often leads to productivity increase, but it makes an Entity Bean incompatible with some databases and it enlarges the amount of code to be written. All transaction management is explicitly performed by a developer.

>
Ques.8> What is EJB QL?

>
Ans.> EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. EJB QL is used for queries of two types of finder methods that are defined in the home interface of an entity bean and which return entity objects.
Select methods, are not exposed to the client, but are used by the Bean Provider to select persistent values maintained by the Persistence Manager or to select entity objects related to the entity bean.

>
Ques.9> The EJB container implements the EJBHome and EJBObject classes. For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes?

>
Ans.>The EJB container maintains an instance pool, which uses these instances for the EJB Home reference irrespective of the client request. While referring the EJB Object classes the container creates a separate instance for each client request. The instance pool maintenance is up to the implementation of the container. Most of the container providers implement the pooling functionality to increase the performance of the application server.

>
Ques.10>What is the difference between ejbStore() and ejbLoad()?What are the key benefits of the EJB technology?

>
Ans.>The difference is : ejbStore() will be called before ejbPassivate() and is used to store the object to persistent database.
ejbLoad() will be called before ejbActivate() and is used to retrieve the object from persistence data store.
Keys benefits are: Rapid application development, Broad industry adoption, Application portability, Protection of IT investment.

>
Ques.11> What are the constraints or drawbacks of container managed EJB’s?

>
Ans.> CMP in beans depends a lot on the EJB vendor implementation and utilities. With some implementations, container-managed entity beans can only be mapped to one table, while other implementations offer multiple table mappings to a single bean. The bottom line, it depends on the container provider being used.

>
Ques.12> Is it possible to share an HttpSession between a JSP and EJB? What happens when we change a value in the HttpSession from inside an EJB?

>
Ans.> We 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 is read-only in the EJB. If anything is altered from inside the EJB, it would not be reflected back to the HttpSession of the Servlet Container.

>
Ques.13> Static variables in EJB should not be relied upon as they may break in clusters. Why?

>
Ans.> Static variables are only fine if they are final otherwise they will break the cluster, each part of the cluster will run in its own JVM.Eg.a method on the EJB is invoked on cluster 1 (we will have two clusters - 1 and 2) that causes value of the static variable to be increased to 101. On the subsequent call to the same EJB from the same client, a cluster 2 may be invoked to handle the request. A value of the static variable in cluster 2 is still 100 because it was not increased yet and therefore our application stops to be consistent.

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...