EJB Interview questions And Answers for freshers as well 1 to 10 year experienced on advance and basic EJB with examples that cover the essentials of EJB means all type of EJB questions covered under this page and also a form is given at the end of this page for those user who want more Interview questions and answer on EJB just need to fill the form and send us we will send all the answers to them and it for both freshers and experienced candidate
|Questions : 1||What is EJB ?|
|Answers : 1||
EJB is a standard for building server side components in JAVA. It specifies an agreement between components and application servers that enables any component to run in any application server. EJB components are deployable and can be imported in to an application server which hosts these components. EJB are not intended for client side they are server side components. They are specially meant for complex server side operations like executing complex algorithms or high volume business transactions.
Above is the most popular architecture in software industry. Three tier architecture has many advantages but the most important of them is that you can change any layer with least changes. For instance you can change the business logic with out making changes to UI or the database side. EJB provides the application layer logic. Application layer logic is also called as middle tier. EJB provides a standard specifications-based way to develop and deploy enterprise-class systems. It’s like moving towards an actually thought JAVA dream that we can run on any vendor platform. This is in contrast to the vendor-specific way we used to develop where each application server had its own way of doing things and where the developer was tied up to a application server.
|Questions : 2||what are the different kind of EJB’s ?|
|Answers : 2||
There are three kinds of EJB’s:-
|Questions : 3||how do you decide whether you should use session, entity or message driven bean?|
|Answers : 3||
Session beans should only implement business logic and work flow.
|Questions : 4||explain EJBHome and EJBObject in EJB?
|Answers : 4||
|Questions : 5||explain the concept of local interfaces ?|
|Answers : 5||
Local objects implement local interface rather than using remote interface. Just to have a comparison below are the steps how the local object works. JAVA client calls the local object. Local object does connection pooling, transactions and security. It then passes calls the bean and when bean completes its work it returns the data to the Local object who then passes the same to the end client. You can understand from the above steps we have by passed completely marshalling and de-marshalling. .
|Questions : 6||What are the limitations of using Local object ?|
|Answers : 6||
Local object only work if you are calling beans in the same process. Second they marshal data by ref rather than by Val. This may speed up your performance but you need to change semantics for the same. So finally it’s a design and the requirement decision. If you are expecting to call beans remotely then using local object will not work.
|Questions : 7||what is Passivation and Activation in EJB?|
|Answers : 7||
When we are dealing with stateful session beans we need to store the client conversation of the bean so that it can be available in client’s next request. But when we talk about server it has limited resources. If the conversation of the bean is large then the server can run out of resource. So in order to preserve resources EJB server swaps this conversational data in memory to hard disk thus allowing memory to be reclaimed. This process of saving the memory data to hard disk is called as “Passivation”. Now when the client comes back the conversational data is again swapped from the hard disk to the bean. This process is called as “Activation”. The container informs the bean that its about to passivate or activate using the "ejbPassivate()" and "ejbActivate()" methods.
|Questions : 8||Can beans who are involved in transaction have “Passivation” process?|
|Answers : 8||
|Questions : 9||How does the server decide which beans to passivate and activate ?|
|Answers : 9||
Most servers use the (LRU) Last Recently Used time as a strategy. Which mean passivate the beans which have been called recently.
|Questions : 10||In what format is the conversational data written to the disk ?|
|Answers : 10||
Bean conversational data is saved in the disk as serialized object. This is possible because “javax.ejb.EnterpriseBean” implements “java.io.Serializable” interface. So during passivation time it converts the bean conversational data to a bit-blob and during activation it just reverses the process.