One can see these questions and answer from interviewee or 
interviewer perspective.
=> These questions and respective answers are my own
understanding of the Subject, and I am not a Subject Matter
Expert in this, so if you have any queries, suggestions,
comments, differece of opinion, please take some time off
your busy schedule to correct me if I am wrong.
your respective comments will be added to the appropriate
place in this page.


EJB Interview Question 1:




Is EJB 2.1 Entity Bean supports,
use of Dependency Injection, 
Interceptors and Java Language
Metadata annotations?

EJB Interview Answer 1:
No, as per EJB2.1, Entity Bean
doesn't support use of 
Dependency Injection, 
Interceptors and Java Language
Metadata annotations.

EJB Interview Question :
Can a client of an Entity Bean
controls lifecycle of Entity  
Bean?

=> If you want to comment/add/differ
with any of the question and/or
answer, please contact Author at
usingframeworks@gmail.com


EJB Interview Question 2: Is EJB 2.1 Entity Bean supports, use of Dependency Injection, Interceptors and Java Language Metadata annotations? EJB Interview Answer 2: No, as per EJB2.1, Entity Bean doesn't support use of Dependency Injection, Interceptors and Java Language Metadata annotations. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 3: Can a client of an Entity Bean controls lifecycle of Entity Bean? EJB Interview Answer 3: Yes, client of Entity Bean can control lifecycle of Entity Bean by using methods from its Home Interface. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 4: If an Entity Bean is in container managed relationship with many other Local Entity Beans and this Entity bean is removed, then how to make sure that all the Entity Beans relationship to this removed entity bean are removal successfully too? EJB Interview Answer 4: By specifying cascade-delete option in container managed relationship, then by removing an Entity Bean instance from one of the container managed relationship, container deleted all the other Entity Bean participating/having relationship with the already removed Entity Bean. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 5: Can the container managed relationship, define cascade-delete for many-to-many container managed relationship? EJB Interview Answer 5: No, cascade-delete option can be used for one-to-one container managed relationship in Entity Beans. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 6: Can I use string valued primary key field value with space at the end or start of value? What will be consequence if used this way? EJB Interview Answer 6: One should not use non-trimmed primary key field value (with space at the start/end of string value), as container and database may trim this value and this way primary key field value comparison may fail. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 7: What is an Interceptor class as per EJB 3.0 specification? EJB Interview Answer 7: Interceptor class is associated with Enterprise Java Bean, so as to get notification in terms of interceptors methods getting called, when certain lifecycle events happens in the associated Enterprise Java Beans. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 8: Are the Programming restrictions related to EJB3.0, applies to Interceptor class as well or not? EJB Interview answer 8: Yes, all the programming restrictions applicable to Enterprise javaBean (as per EJB 3.0), applies to Interceptor as well. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 9: Is it mandatory to have a no-arg constructor in Interceptor class? EJB Interview Answer 9: Yes, it is mandatory to have a no-arg constructor in Interceptor class? => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 10: What is the lifecycle of Interceptor class associated with an Enterprise JavaBean? EJB Interview Answer 10: Lifecycle of Interceptor class is associated with an Enterprise JavaBean is same as that of the Enterprise javabean with which it is associated. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 11: Can an Interceptor perform a lookup (JNDI) operation? EJB Interview answer 11: Yes, Interceptor can be injected with EJBContext of the Bean it is associated with. So Interceptor can access JNDI naming context of the Enterprise JavaBean, with which it is associated with. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 12: How many different ways one can define Interceptor for Enterprise JavaBean 3.0? EJB Interview Answer 12: Interceptor methods can be defined within the Enterprise Java bean body OR Interceptor methods can be defined in a separate Interceptor class. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview question 13: How Interceptors are annotated in EJB 3.0? EJB Interview answer 13: If a method is annotated as @AroundInvoke , then it is the Interceptor method type defined in the EJB 3.0. If @Interceptors(classname.class) is placed in class level annotation, then "classname.class" is the interceptor class to be intercepted for lifecycle of EJB3.0 with various annotations like @PostConstruct, @PreDestroy, @PostActivate, @PrePassivate. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 14: Who controls lifecycle of stateful session bean in EJB 3.0? EJB Interview Answer 14: Generally client to the Session Bean (Stateful), controls life cycle of the stateful session bean. But in some cases when timeout as defined in deployment descriptor is reached, then container may also terminate/remove a stateful session bean's instance, and in case of server/container failure as well, container may terminate/remove a stateful session bean's instance. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 15: What are the lifecycle of Session Bean? EJB Interview Answer 15: Stateless Session bean: doesn't exist, pool, active Stateful Session bean: doesn't exist, pool, active, passivate, remove. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 16: Is there any scheduling activity be programmed in EJB context? EJB Interview Answer 16: EJB3.0 has timer service, and there is a scheduler Quartz Framework to use. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 17: Exceptions in EJB 3.0 (Enterprise JavaBeans)? Enterprise JavaBean answer 17: There are two types of exceptions in EJB3.0, those are Application Exception and System exception. Application exceptions, those extends java.lang.Exception, These exceptions can be CreateException, RemoveException, FinderException. System exception are those that occurs due to exception of type EJBException, RuntimeException and RemoteException. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB question 18: Will there be a rollback in transaction if there is application exception, occurs while executing EJB (Enterprise JavaBean)? EJB answer 18: I think, NO, there won't be automatic transaction rollback in case of application exception being raised inside container. But a transaction can be programmatically marked as rollbackonly, by executing EJBContext.setRollbackOnly() method. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 19. Is it possible to define any method as callback method in Enterprise JavaBeans (EJB) version 3.0? EJB Interview Answer 19: Yes, as per EJB 3.0 API, annotations like @PreDestroy, @PostConstruct, @PrePassivate and @PostActivate can be placed before any method in Enterprise Java Bean to use it as callback method for the EJB. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 20. While using Dependency Injection in Enterprise Java beans, as per EJB 3.0 specification, when should the business method that uses variables (or object reference) as defined in Dependency Injection be called without fear of getting NullPointerException? EJB Interview Answer 20: As per EJB3.0 specification, container initiates dependency injection, and injects proper dependency object or reference into the variable/reference defined within Enterprise Java Bean, before client invokes business method that uses this reference, thus there is no question of NullPointerException arises. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB interview quesion 21: In EJB 3.0, How a business method in EJB be exposed as Web Service? EJB Interview Answer 21: @WebMethod annotation can be used to mark a business method that can be exposed as web service. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB interview quesion 22: In EJB 3.0 API, is it mandatory to have Home interface for Session Bean (Stateless/ Stateful)? EJB Interview Answer 22: No, in EJB 3.0 API, Session Beans (Stateful/ Stateless) need not have home interface, defined. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB interview question 23: Then what will be compatibility of EJB1.1 API, in EJB 3.0 compatible application server? EJB interview answer 23: Yes, All versions of EJB, like EJB 1.1, EJB 2.0, EJB 2.1 should still be compatible with the latest EJB3.0 API based application container. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB interview question 24: In EJB 3.0 API, is it mandatory for session bean's business interface extends EJBObject or EJBLocalObject interface? EJB interview answer 24: No, in EJB3.0 API, business interface of session bean should not extend EJBObject or EJBLocalObject interface. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 25: Is EJB 2.1 Entity Bean supports, use of Dependency Injection, Interceptors and Java Language Metadata annotations? EJB Interview Answer 25: No, as per EJB2.1, Entity Bean doesn't support use of Dependency Injection, Interceptors and Java Language Metadata annotations. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 26: Can a client of an Entity Bean controls lifecycle of Entity Bean? => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 27: Is EJB 2.1 Entity Bean supports, use of Dependency Injection, Interceptors and Java Language Metadata annotations? EJB Interview Answer 27: No, as per EJB2.1, Entity Bean doesn't support use of Dependency Injection, Interceptors and Java Language Metadata annotations. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 28: Can a client of an Entity Bean controls lifecycle of Entity Bean? EJB Interview Answer 28: Yes, client of Entity Bean can control lifecycle of Entity Bean by using methods from its Home Interface. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 29: If an Entity Bean is in container managed relationship with many other Local Entity Beans and this Entity bean is removed, then how to make sure that all the Entity Beans relationship to this removed entity bean are removal successfully too? EJB Interview Answer 29: By specifying cascade-delete option in container managed relationship, then by removing an Entity Bean instance from one of the container managed relationship, container deleted all the other Entity Bean participating/having relationship with the already removed Entity Bean. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 30: Can the container managed relationship, define cascade-delete for many-to-many container managed relationship? EJB Interview Answer 30: No, cascade-delete option can be used for one-to-one container managed relationship in Entity Beans. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 31: Can I use string valued primary key field value with space at the end or start of value? What will be consequence if used this way? EJB Interview Answer 31: One should not use non-trimmed primary key field value (with space at the start/end of string value), as container and database may trim this value and this way primary key field value comparison may fail. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 32: What is an Interceptor class as per EJB 3.0 specification? EJB Interview Answer 32: Interceptor class is associated with Enterprise Java Bean, so as to get notification in terms of interceptors methods getting called, when certain lifecycle events happens in the associated Enterprise Java Beans. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 33: Are the Programming restrictions related to EJB3.0, applies to Interceptor class as well or not? EJB Interview answer 33: Yes, all the programming restrictions applicable to Enterprise javaBean (as per EJB 3.0), applies to Interceptor as well. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 34: Is it mandatory to have a no-arg constructor in Interceptor class? EJB Interview Answer 34: Yes, it is mandatory to have a no-arg constructor in Interceptor class? => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 35: What is the lifecycle of Interceptor class associated with an Enterprise JavaBean? EJB Interview Answer 35: Lifecycle of Interceptor class is associated with an Enterprise JavaBean is same as that of the Enterprise Java Bean with which it is associated. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 36: Can an Interceptor perform a lookup (JNDI) operation? EJB Interview answer 36: Yes, Interceptor can be injected with EJBContext of the Bean it is associated with. So Interceptor can access JNDI naming context of the Enterprise JavaBean, with which it is associated with. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 37: How many different ways one can define Interceptor for Enterprise JavaBean 3.0? EJB Interview Answer 37: Interceptor methods can be defined within the Enterprise Java bean body OR Interceptor methods can be defined in a separate Interceptor class. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview question 38: How Interceptors are annotated in EJB 3.0? EJB Interview answer 38: If a method is annotated as @AroundInvoke , then it is the Interceptor method type defined in the EJB 3.0. If @Interceptors(classname.class) is placed in class level annotation, then "classname.class" is the interceptor class to be intercepted for lifecycle of EJB3.0 with various annotations like @PostConstruct, @PreDestroy, @PostActivate, @PrePassivate. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com EJB Interview Question 39: Who controls lifecycle of stateful session bean in EJB 3.0? EJB Interview Answer 39: Generally client to the Session Bean (Stateful), controls life cycle of the stateful session bean. But in some cases when timeout as defined in deployment descriptor is reached, then container may also terminate/remove a stateful session bean's instance, and in case of server/container failure as well, container may terminate/remove a stateful session bean's instance. => If you want to comment/add/differ with any of the question and/or answer, please contact Author at usingframeworks@gmail.com Disclaim: These questions and answer are to the best of my understanding, please refer to EJB 3.0 specification (http://java.sun.com/products/ejb/docs.html) for details.
Copyright © 2009-2010, Interview-Questions-Tips-Forum, All Rights Reserved.

These Pages are NOT affiliated in any form with Weebly.com