SCBD Beta Exam Information and Mocks

Topic Exam Name Exam Code Exam Type No. of Qs Time Exam Validity E-mail No. of Objectives Acknowledgement Prepared by Last Modification Date Version Answer Sun Certified Business Component Developer for J2EE 311-090 Multiple Choice and Drag and Drop questions 183 4 hours JUNE 6 - JULY 7, 2003 register4beta@central.sun.com 54 under 14 categories Kathy Sierra, Bert Bates, Valentin Crettaz, JavaRanch Muhammad Ashikuzzaman (Fahim) 27-06-2003 1.4

What is SCBCD?
SCBCD is the abbreviation for Sun Certified Business Component Developer for Java 2 Platform, Enterprise Edition. This is another J2EE certification from sun not to be confused with SCWCD. SCWCD focuses on the Web tier (Servlets, JSPs and other web components stuff), while SCBCD is dedicated to the Business tier (EJBs). You may find an introduction on web tier/business tier descriptions from J2EE tutorial of Sun at http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview3.html#wp81104

SCJD

SCJP IT Professional

SCBCD

SCWCD

SCEA

Figure-1: The road towards SCBCD Certificate

Objectives (Short)

Page 1 of 28

o o o o o o o o o o o o o o

Client View of a Session Bean EJB Overview Session Bean Component Contract Session Bean Lifecycle Component Contract for Container-Managed Persistence (CMP) Client View of an Entity CMP Entity Bean Lifecycle Entity Beans EJB-QL Message-Driven Bean Component Contract Transactions Exceptions Enterprise Bean Environment Security Management

Objectives (Details)
1 EJB Overview 1.1 Identify the use, benefits, and characteristics of Enterprise JavaBeans Technology, for version 2.0 of the EJB specification. 1.2 Identify EJB 2.0 container requirements – spec p-56. 1.3 Identify correct and incorrect statements or examples about EJB programming restrictions – spec p-494. 1.4 Match EJB roles with the corresponding description of the role's responsibilities, where the description may include deployment descriptor information – spec p-33. 1.5 Given a list, identify which are requirements for an EJB-jar file – spec p-46, 487. 2 Client View of a Session Bean 2.1 Identify correct and incorrect statements or examples about the client view of a session bean's local and remote home interfaces, including the code used by a client to locate a session bean's home interface. 2.2 Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces. 3 Session Bean Component Contract 3.1 Identify correct and incorrect statements or examples about session beans, including conversational state, the SessionBean interface, and create methods. 3.2 Identify the use of, and the behavior of, the ejbPassivate method in a session bean, including the responsibilities of both the container and the bean provider. 3.3 Identify the interface and method for each of the following: Retrieve the session bean's remote home interface, Retrieve the session bean's local component interface, Determine if the session bean's caller has a particular role, Allow the instance to mark the current transaction as a roleback, Retrieve the UserTransaction interface, Prepare the instance for re-use following passivation, Release resources prior to removal, Identify the invoker of the bean instance's component interface, Be notified that a new transaction has begun, be notified that the current transaction has completed. 3.4 Match correct descriptions about purpose and function with which session bean type they apply to: stateless, stateful, or both. 3.5 Given a list of responsibilities related to session beans, identify those which are the responsibility of the session bean provider, and those which are the responsibility of the EJB container provider. 3.6 Given a list of requirements, identify those which are the requirements for a session bean class, remote component interface, remote home interface, create methods, business methods, local component interface, remote component interface. 4 Session Bean Lifecycle

Page 2 of 28

4.1 Identify correct and incorrect statements or examples about the lifecycle of a stateful or stateless session bean instance. 4.2 Given a list of methods of a stateful or stateless session bean class, define which of the following operations can be performed from each of those methods: SessionContext interface methods, UserTransaction methods, JNDI access to java:comp/env environment naming context, resource manager access and other enterprise bean access. 4.3 Given a list of scenarios, identify which will result in an ejbRemove method not being being called on a bean instance. 5 Client View of an Entity 5.1 Identify correct and incorrect statements or examples about the client view of an entity bean's local and remote home interface, including the code used to locate an entity bean's home interface, and the home interface methods provided to the client. 5.2 Identify correct and incorrect statements or examples about the client view of an entity bean's local component interface (EJBLocalObject). 5.3 Identify correct and incorrect statements or examples about the client view of a entity bean's remote component interface (EJBObject). 5.4 Identify the use, syntax, and behavior of, the following entity bean home method types, for CMP: finder methods, create methods, remove methods, and home methods. 6 Component Contract for Container-Managed Persistence (CMP) 6.1 Identify correct and incorrect statements or examples about the entity bean provider's view and programming contract for CMP, including the requirements for a CMP entity bean. 6.2 Identify correct and incorrect statements or examples about persistent relationships, remove protocols, and about the abstract schema type, of a CMP entity bean. 6.3 Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment, and relationship updating, in a CMP bean. 6.4 Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relationshiprole, cmr-field, cmr-field-type, and relationship-role-source. 6.5 Identify correctly-implemented deployment descriptor elements for a CMP bean (including containermanaged relationships). 6.6 Identify the interface(s) and methods a CMP entity bean must and must not implement. 7 CMP Entity Bean Lifecycle 7.1 Identify correct and incorrect statements or examples about the lifecycle of a CMP entity bean. 7.2 From a list, identify the purpose, behavior, and responsibilities of the bean provider for a CMP entity bean, including but not limited to: setEntityContext, unsetEntityContext, ejbCreate, ejbPostCreate, ejbActivate, ejbPassivat, ejbRemove, ejbLoad, ejbStore, ejbFind, ejbHome, and ejbSelect. 7.3 From a list, identify the responsibility of the container for a CMP entity bean, including but not limited to: setEntityContext, unsetEntityContext, ejbCreate, ejbPostCreate, ejbActivate, ejbPassivate, ejbRemove, ejbLoad, ejbStore, ejbFind, ejbHome, and ejbSelect. 8 Entity Beans 8.1 From a list of behaviors, match them with the appropriate EntityContext method responsible for that behavior. 8.2 Identify correct and incorrect statements or examples about an entity bean's primary key and object identity. 9 EJB-QL 9.1 Identify correct and incorrect syntax for an EJB QL query including the SELECT, FROM, and WHERE clause. 9.2 Identify correct and incorrect statements or examples about the purpose and use of EJB QL. 9.3 Identify correct and incorrect conditional expressions, between expression, in expressions, like expressions, and comparison expressions.

Page 3 of 28

10 Message-Driven Bean Component Contract 10.1 Identify correct and incorrect statements or examples about the client view of a message-driven bean, and the lifecycle of a message-driven bean. 10.2 Identify the interface(s) and methods a JMS Messaged-Driven bean must implement. 10.3 Identify the use and behavior of the MessageDrivenContext interface methods. 10.4 From a list, identify the responsibility of the bean provider, and the responsibility of the container provider for a message-driven bean. 11 Transactions 11.1 Identify correct and incorrect statements or examples about EJB transactions, including bean-managed transaction demarcation, and container-managed transaction demarcation. 11.2 Identify correct and incorrect statements about the Application Assembler's responsibilities, including the use of deployment descriptor elements related to transactions, and the identification of the methods of a particular bean type for which a transaction attribute must be specified. 11.3 Given a list of transaction behaviors, match them with the appropriate transaction attribute. 11.4 Given a list of responsibilities, identify whose which are the container's with respect to transactions, including the handling of getRollbackOnly, setRollbackOnly, getUserTransaction, SessionSynchronzation callbacks, for both container and bean-managed transactions. 12 Exceptions 12.1 Identify correct and incorrect statements or examples about exception handling in EJB. 12.2 Given a list of responsibilities related to exceptions, identify those which are the bean provider's, and those which are the responsibility of the container provider. Be prepared to recognize responsibilities for which neither the bean or container provider are resopnsible. 12.3 Identify correct and incorrect statements or examples about application exceptions and system exceptions in entity beans, session beans, and message-driven beans. 12.4 Given a particular method condition, identify the following: whether an exception will be thrown, the type of exception thrown, the container's action, and the client's view. 12.5 Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation. 13 Enterprise Bean Environment 13.1 Identify correct and incorrect statements or examples about an enterprise bean's environment JNDI naming. 13.2 Identify correct and incorrect statements about the purpose and/or use of the deployment descriptor elements for environment entrys, ejb references, and resource manager connection factory references, including whether a given code listing is appropriate and correct with respect to a particular deployment descriptor element. 13.3 Given a list of responsibilities, identify which belong to the deployer, bean provider, application assembler, container provider, system administrator, or any combination. 14 Security Management 14.1 Identify correct and incorrect statements about the EJB support for security management including security roles, security role references, and method permissions. 14.2 From a list of responsibilities, identify which belong to the application assembler, bean provider, deployer, container provider, or system administrator. 14.3 Given a code listing, determine whether it is a legal and/or appropriate way to programmatically access a caller's security context. 14.4 Given a security-related deployment descriptor tag, identify correct and incorrect statements and/or code related to that tag.

Study Resources
* EJB 2.0 Specification - http://java.sun.com/j2ee/1.3/download.html#sdk * Enterprise JavaBeans, 3rd Edition by Monson-Haefel (O’ Reilly)

Page 4 of 28

* * * *

Mastering EJB, 2nd Edition by Ed Roman (Wiley) JDiscuss Mock Exam on SCBCD at http://www.jdiscuss.com/Enthuse/jsp/ShowAvailableTests.jsp Valentine’s Exception Handling Cheat Sheet at http://www.valoxo.ch/jr/ExceptionHandling.pdf Instructions to download sample chapters of Kathy’s SCBCD book -

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=70&t=000107 * BrainBench’s exam on EJB – http://www.brainbench.com * Erik Kaellgren’s mock at http://kaellgren.freewebpage.org/ * HTML version of this note - http://www.geocities.com/francisco_guimaraes/ashik * Whizlabs SCDBCD Mock Exam Simulator - http://www.whizlabs.com/scbcd/scbcd.html * Kathy and Bert’s Head First Java http://www.amazon.com/exec/obidos/ASIN/0596005717/electricporkchop * Valentine’s cheat sheets - http://www.valoxo.ch/jr/cheatsheets.html * JDiscuss free mock tests of SCBCD http://www.jdiscuss.com/Enthuse/jsp/ShowAvailableTests.jsp

Valentine’s Mapping between Exam Objectives and EJB 2.0 Spec
1. EJB Overview 1.1 -> 1.2, 2.1, 2.3 1.2 -> 24.2 1.3 -> 24.1.2 1.4 -> 25 + *'s responsibilities sections all over the spec 1.5 -> 23.3 2. Client View of a Session Bean 2.1 -> 6.2.1, 6.3 2.2 -> 6.5 3. Session Bean Component Contract 3.1 -> 7.4, 7.5.1, 7.5.5, 7.9.1 3.2 -> 7.4.1, 7.7.5 3.3 -> 7.5.1, 7.5.2, 7.5.3 3.4 -> 7.6, 7.7, 7.8, 7.9 3.5 -> 7.10, 7.11 3.6 -> 7.10.2, 7.10.5, 7.10.6, 7.10.3, 7.10.4, 7.10.7, 7.10.8 4. Session Bean Lifecycle 4.1 -> 7.6, 7.8 4.2 -> 7.6.1, 7.8.2 4.3 -> 7.6.3 5. Client View of an Entity 5.1 -> 9.5, 9.6, 9.4.1 5.2 -> 9.10 5.3 -> 9.9 5.4 -> 9.5, 9.6 6. Component Contract for Container-managed Persistence (CMP) 6.1 -> 10.3, 10.3.1 6.2 -> 10.3.2, 10.3.4 6.3 -> 10.3.6, 10.3.7, 10.3.8 6.4 -> 10.3.13 6.5 -> 10.3.13 6.6 -> 10.6 7. CMP Entity Bean Lifecycle 7.1 -> 10.5 7.2 -> 10.5.2, 10.6 7.3 -> 10.5.3, 10.7

Page 5 of 28

8. Entity Beans 8.1 -> 10.5.4 8.2 -> 10.8, 10.3.5 9. EJB-QL 9.1 -> 11.2.6, 11.2.7, 11.2.8 9.2 -> 11.3 9.3 -> 11.2.7.5, 11.2.7.7, 11.2.7.8, 11.2.7.9, 11.2.7.10, 11.2.7.11 10. Message-Driven Bean Component Contract 10.1 -> 15.3, 15.5 10.2 -> 15.4 10.3 -> 15.4.3 10.4 -> 15.7, 15.8 11. Transactions 11.1 -> 17.2, 17.3.1, 17.3.3, 17.3.4 11.2 -> 17.4, 17.7.4 11.3 -> 17.4.1, 17.6.2, 17.6.3 11.4 -> 17.6.1, 17.6.2, 17.6.3 12. Exceptions 12.1 -> 18 12.2 -> 18.2, 18.3 12.3 -> 18.2, 18.3.1, 18.3.2, 18.4 12.4 -> 18.2, 18.3 12.5 -> 18.4 13. Enterprise Bean Environment 13.1 -> 20.2 13.2 -> 20.2, 20.3, 20.4 13.3 -> 20.2, 20.3, 20.4, 20.5 14. Security Management 14.1 -> 21.2.5.3, 21.3.1, 21.3.2, 21.3.3, 21.4.2 14.2 -> 21.2, 21.3, 21.4, 21.6, 21.7, 22.1, 22.2, 22.3, 22.4 14.3 -> 21.2.5 14.4 -> 21.2.5.3, 21.3, 21.4.2, 21.4.3, 22.3

Things You Can Ignore for the Exam (Kathy)
* Anything at all about EJB 1.1 (or earlier) * Anything at all about EJB 2.1 * Anything at all about non-EJB parts of the J2EE spec, in other words, no web components. * Anything about what is in the EJBMetaData interface. You DO need to know how to get it (especially so that you can recognize when you are looking at a local vs. remote home -remember, the geEJBMetaData() method is ONLY in the remote home, so if you see that method, it's a Big Clue...) * Details about the 'handles'. You DO need to know under which circumstances they are available (remote interfaces ONLY!), and what they're for, but that's it. * Anything about BMP (so, chapter 12 and 13 are out, as well as chapter 14 about CMP 1.1) * Deep details about JMS. You *do* need to know about message-driven beans, per the objectives, but you will only have a handful of questions on MDB, and you aren't expected to be a JMS expert. * Anything about isolation levels (other than knowing that you can't control them from EJB! And that the 2.0 spec really has nothing to say about isolation levels) * Chapter 19!! (Support for distribution and interoperability) The whole thing. You DO need to know that IIOP is the assumed wire protocol (even if it isn't used) and that this is why you need

Page 6 of 28

PortableRemoteObject.narrow() with your remote home stubs, but this is covered in the objectives on "client view". So, no details on propagation of security, IDL, etc. * Every possible exact tag syntax for the DD. BUT... be warned that there *are* questions that will expect you to know WHICH tags/elements are used in a particular scenario. You will need to recognize which tags make up a particular element. Especially the ones that matter. So you will need to know the difference between, say, security roles and security role *references*, but you won't necessarily have to memorize the exact tag structure. Still, I'd become pretty familiar with the DD. Yes we DO expect that you might use tools to generate the DD, but as a developer it is still YOU who must supply the information to the tool, so you need to know about each part of the DD in pretty good detail. * Anything about security that is not covered in the spec. So, you don't need to know about authorization mechanisms. You DO need to know about roles/references, and how to use programmatic security info (getCallerPrincipal() and isCallerInRole(), and know about the 'run-as' feature in 2.0) * Anything in the J2EE API (including things that have been promoted to J2SE as of 1.4), EXCEPT for the interfaces / classes covered in the objectives: So, you DO need to know exactly what is in the EJBObject, EJBHome, EJBLocalHome, EJBLocalObject, SessionBean, EnterpriseBean, MessageDrivenBean, EntityBean, SessionContext, EntityContext,MessageDrivenContext, MessageListener, UserTransaction, and... I think that's it. Let me know if I left something out here... * The APIs and technology requirements of EJB, EXCEPT you need to know exactly WHICH are part of EJB. In other words, you MUST know that JavaMail 1.1 (sending only) is included in any EJB 2.0 container, but you do NOT need to know anything about the JavaMail API. Same for JNDI (except for the things covered in other objectives, mainly: client lookup and a bean's environment (java:comp/env) You MUST know that JDBC, JTA, JMS, JAXP are all part of the EJB 2.0 specification. But you don't need to know how they work, beyond what you need for the other objectives, mainly: javax.transaction.UserTransaction (for JTA) and the MessageListener interface (for JMS). Oh yeah, you do need to know about JMS topics and queues, but not in detail. * ANYTHING that is vendor-specific. * ANYTHING that involves a particular app server, including the reference implementation. I cannot think of a single question that is not taken directly from the spec. What makes the questions challenging is that the questions expect you to *infer* certain things from looking at code or a scenario. For example, if you see a client doing a lookup, and the client does NOT perform a narrow on the home, AND you are told to assume the client code is legal... what does this tell you? That the interface is local! But of course, that's not what the question will ask... it might ask you if you can use that same reference to call getHomeHandle(), which you will say NO, because you can see from the code that you're working with a local interface, and therefore getHomeHandle() does not apply. Additionally RMI -- This is covered on the exam only to the extend that you must know what it means to be 'remote'. For example, you must know that: * EJBObject and EJBHome both extend java.rmi.Remote, which is a marker interface (no methods to implement with Remote). * ALL methods in a remote interface MUST declare java.rmi.RemoteException * You must understand, but not know any details about, the fact that a stub class is generated from the implementation of the remote interface, and that the container is responsible for BOTH of the those classes -- the implementation of your remote interface AND the stub made from that interface. (And of course this is true for both Home and Component interfaces) * You do NOT have to know about: * rmic * skeletons * how to 'export' a remote object * how to place the remote object in the naming service * the wire protocol, except you MUST know that you are to assume IIOP. Implication? You MUST 'narrow' the Home reference if it is a remote home interface. * that arguments and return types MUST be serializable if they are passed in or out of remote methods.

Page 7 of 28

JNDI -- you do not need to know much about the JNDI API. But you must know: * What it means to get a JNDI Context and InitialContext. * How to do a client lookup (initialContext.lookup("foo")) * Most importantly, you must understand the bean's own JNDI environment (java:comp/env), which is the bean's own private space for looking up: 1) references to other beans (EJB references) 2) resources, such as JDBC,(resource factory references) 3) environment entrys (deploy-time customized values, like properties) Be sure you know EXACTLY how those things are used both in the deployment descriptor, and in code, and be sure you know WHICH EJB role is responsible for which part... for example, you must know that the deployer is responsible for *ensuring* that all environment entrys have a valid value, even though it is often the app assembler who puts in the value. And be sure you know that there are three levels of mapping for, say, configuring a database into the EJB app -- the database itself is configured into the server, then the factory reference is given a name in JNDI, and then a logical name (that may NOT be the JNDI name!) is used in code (this is the resource factory reference name in the DD), and that logical name must be mapped back to the *real* JNDI name, at deploy time.

Last Minute Tips by Kathy
CODE EXAMPLES: Assuming that the code is legal (and you aren't tested on any Java syntax! -- If the code is illegal, that's because it won't work according to EJB rules or APIs) * If you see a call to getRollbackOnly(), what does that tell you? -- this MUST be a CMT bean! BMT beans can't call this, because they can use only the UserTransaction interface, which has getStatus(), but not setRollbackOnly() * If you see a call to setRollbackOnly(), what does this tell you? -- NOTHING, until you look at which interface the method was invoked on -- is it EJBContext? Then you have a CMT bean. UserTransaction? BMT bean. * If you see code that does not perform a narrow on the home stub, what does this tell you? -- this is a local client! * If you see code that *successfully* invokes getPrimaryKey(), what does that tell you? -- this is an entity bean * If you see code that successfully invokes getHandle(), what does this tell you? -- that you are looking at a remote interface; local interfaces aren't involved with handles -- if you see code that invokes a remove(pk) on the home, you know you are dealing with an entity bean (and that you are seeing code invoked on the home) -- if you see code that invokes a remove(handle), you know you are looking at a remote client -could be session or entity -- and that you are seeing code invoked on the home -- if you see the no-arg remove(), then it must be the component interface SECURITY: * if you see isCallerInRole(aString), what do you know? - you are NOT looking at a message-driven bean - the method is invoked on an EJBContext - "aString" must be declared in the deployment descriptor as a security role REFERENCE -- be SURE you understand the difference between security ROLE and security role REFERENCE the reference is something the bean provider must put in, to tell everyone that he has hard-coded a role String. Remember, the bean provider does not *really* know what the actual security roles are in the company, so he just makes one up that sounds good, and then describes it in the deployment descriptor. The someone *else* must map from security role REFERENCES to security ROLES in the deployment descriptor (often this is the Application Asssembler), and finally, the Deployer must map from security ROLES (in the deployment descriptor) to *real* security roles for principals/users/groups in the real "operational environment". This final mapping is NOT part of the EJB spec! It is NOT done in the ejb-jar.xml document. Session Beans: -- know the lifecycle --- stateless session beans ejbCreate is not in any way connected to a client calling create -- same with remove -- passivation is ONLY for stateFUL beans. -- they will never be passivated while in a transaction! -- If a stateful bean times out while passivated, the container will NOT "wake the bean up" (i.e.

Page 8 of 28

activate) just to kill it. So, the bean will be killed WITHOUT getting a remove() call. So don't rely on remove() [which will also be missed if there's a server crash] -- be sure you know that setSessionContext is called very early in the bean's life, and only ONCE (this is true for all beans), and that within setSessionContext, you do not yet have access to your component interface, you must wait until you are in ejbCreate! -- do not do ANYTHING in your bean's constructors. An object does not have any "beanness" at that point. It is *legal* to put some code there, but don't. -- a transaction on a stateFUL bean can span multiple invocations from the client. In other words, you can start a tx in one method and then leave it uncomplete when the method ends. -- a stateLESS bean must complete its tx before the end of the method -- a stateLESS bean must NOT implement SessionSynchronization TRANSACTIONS: -- BMT is for Session (both types) and Message-driven beans ONLY --- A BMT bean will not run in a tx unless it is the tx started by the bean itself. -- A BMT bean's transaction will propogate to other beans that the BMT bean calls. -- a BMT bean must not start one tx before completing the previous one. -- BMT means must never call setRollbackOnly or getRollbackOnly on the context. CMP: -- know the SIX transaction attributes, and know exactly how they will behave, depending on whether or not the calling method is in a transaction. -- know that MANDATORY and NEVER will throw exceptions -- which transaction attributes can an mdb have? Only Required and NotSupported! The others do not make any sense for an MDB, since it can NEVER be invoked with an existing tx (it is only the container who invokes the onMessage()) -- know that a bean with SessionSynchronization must NOT use Never, NotSupported, or Supports. In other words, a bean that wants to know about its tx status better be in a transaction! -- look up in the spec what it means to have "an unspecified transaction context", and understand the circumstances in which a method will run that way. -- know exactly WHICH methods must have a tx attribute; - Session: just the business methods from component interface, nothing else -- Message: just onMessage() -- Entity -- all the business methods, the methods YOU define in the home (create(), finders, etc.) AND the three remove() methods from the two interfaces! (or two remove() methods if its local) EXCEPTIONS: -- know the difference between System and Application exceptions. -- most importantly, know that only System exceptions result in an automatic rollback. For application exceptions. -- Know that application exceptions go to the client AS-IS (in other words, exactly as they were thrown by the bean / conainer) -- System exceptions are wrapped in a RemoteException for remote clients -- local clients WILL get an EJBException, but a remote client never will. -- you must know which are checked and which are not, so that you know what your responsibility is for declaring them, and what the client's responsbilitiy is. EJBObject is a runtime exception, so you can throw it anytime without declaring Know the FIVE application exceptions from javax.ejb: Finder --ObjectNotFound Create -- DuplicateKeyException Remove Know that a client might not always GET the DuplicateKeyException even when that is the problem. Don't count on it. Know the difference between ObjectNotFound and NoSuchObject. ObjectNotFound is ONLY for finder methods, and only for single-row finder methods. To remember: "ObjectNotFOUND goes with FINDER methods" NoSuchObject means that at one point the client had a reference to an EJBObject, but that EJBObject is no longer there -- in other words, you have a stub but the thing it connected to (the remote object) is gone. Know that NoSuchObject is a standard RMI exception, but that now there is a NoSuchLocalObject exception as well.

Page 9 of 28

Know that even though RemoteException is a checked exception, is is NOT an application exception. Anything else you declare in one of your interfaces IS an application exception (which must also be a checked exception). Know that system exceptions cause the bean to be discarded, application exceptions do not. Know what it MEANS to discard a bean: -- stateless session clients can still use their EJBObject reference (container just grabs a different one from the pool) -- stateful session beans will have to go back through the home again and start over -- entity beans can still use their EJBObject reference (the pool...) When you believe a client cannot recover from something that YOU caught in your bean code, throw an EJBException to the container. If you are throwing an application exception, then you must decide yourself whether the tx should be rolled back. Know the SCOPE of java:comp/env --- it is per BEAN, not per JAR or application -- Know that it is the bean's private environment. Understand: * Environment Entries -- if the bean provider coded one in, the provider MUST announce that in the DD -- the app assembler or bean provider can put in the value (probably the app assembler) but the Deployer MUST ensure that there is a value * be sure you know how the DD element matches what you put in code to access it. (java:comp/env/foo should be just "foo" in the DD, without the quotes) * Be sure you know the TYPES that an environment entry can be! Be sure you understand that tx attributes in the DD can be specified on a method-per-method basis, and KNOW what the elements look like for specifying a tx attribute. Be sure you understand how the wildcard "*" works for this. Know the DD tags for the security role references and roles Know what it means to access a bean from a bean: that you use an ejb reference. Be familiar with the DDelement, and how it maches the code; java:comp/env/ejb/Advice means: "ejb/Advice" in the DD -- know all the rules for the circumstances for load and store, etc. if you see ejbLoad, you know you are looking at an entity bean, and you know that the bean has already been populated with the state from the persistent store (because we are ONLY talking about CMP) -- I'm not going to go into the CMP stuff here (too much), so just be familiar with the way that CMP and CMR works!!! Strategies for Dealing with RemoteException or EJBException in Client (Valentine)

Page 10 of 28

Figure-2: Strategies for Dealing with RemoteException or EJBException in Client

What to Know from Syed AliRaza Zaidi
Security: What other tags should be written in <run-As> tag ? Whose responsibility is to define security role refrence tag? What other tags can be in security refrence tag and security role tag? Whose responsibilty is to define security roles ? What should must be define in a deployment Descriptor to use isCallerInRole(string s) method? What type of object is returned by getCallerPrincipal() method? What class or interface contains Programmatic security methods? What is requirement for Programmatic Security? EJB-QL: You should You should You should You should You should You should You should You should You should You should contain You should bean? You should know how to write a query know whats illegal in EJB-QL query know about WHERE , FROM , IN ,AS clauses know about Pathexpressions know about collections know that ejbSelect<Methods>are written in bean class not in home interface know that ejbFind<Methods> are written in home interface know the difference between find and select method be aware of PrimaryKey field, class , type be aware of defining custom composite primary key class and the things it need to know that what variables should be part of both PrimaryKey class as well as the cmp know about EJB-QL and Abstract Presistance Schema

Entity Beans / Session Beans / MDB: You should know Life cycle of entiy bean Memorize sequence diagrams Learn them inside out their Limitation from Specification

Page 11 of 28

Statless beans in context of transaction Statefull bean and conversational state Transactions: Know how to define CMT by using Deployment Descriptor Know how to define BMT All transaction attributes should be remembered You should know all things related to transactions and Exceptions Exceptions : You should know the difference between two System and Application Exceptions You should know actions and effects of these exception on container transactions You should be able to identify the exceptions Environment: You should know about JNDI-ENC and resources you can get from it

Kathy as a reply of a question
But your other questions: RMI -- This is covered on the exam only to the extend that you must know what it means to be 'remote'. For example, you must know that: * EJBObject and EJBHome both extend java.rmi.Remote, which is a marker interface (no methods to implement with Remote). * ALL methods in a remote interface MUST declare java.rmi.RemoteException * You must understand, but not know any details about, the fact that a stub class is generated from the implementation of the remote interface, and that the container is responsible for BOTH of the those classes -- the implementation of your remote interface AND the stub made from that interface. (And of course this is true for both Home and Component interfaces) * You do NOT have to know about: * rmic * skeletons * how to 'export' a remote object * how to place the remote object in the naming service * the wire protocol, except you MUST know that you are to assume IIOP. Implication? You MUST 'narrow' the Home reference if it is a remote home interface. * that arguments and return types MUST be serializable if they are passed in or out of remote methods. JNDI -- you do not need to know much about the JNDI API. But you must know: * What it means to get a JNDI Context and InitialContext. * How to do a client lookup (initialContext.lookup("foo")) * Most importantly, you must understand the bean's own JNDI environment (java:comp/env), which is the bean's own private space for looking up: 1) references to other beans (EJB references) 2) resources, such as JDBC,(resource factory references) 3) environment entrys (deploy-time customized values, like properties) Be sure you know EXACTLY how those things are used both in the deployment descriptor, and in code, and be sure you know WHICH EJB role is responsible for which part... for example, you must know that the deployer is responsible for *ensuring* that all environment entrys have a valid value, even though it is often the app assembler who puts in the value. And be sure you know that there are three levels of mapping for, say, configuring a database into the EJB app -- the database itself is configured into the server, then the factory reference is given a name in JNDI, and then a logical name (that may NOT be the JNDI name!) is used in code (this is the resource factory reference name in the DD), and that logical name must be mapped back to the *real* JNDI name, at deploy time. Sockets -- NOT part of the exam, except for you to know that ServerSockets are not allowed (i.e listening on a Socket) but that Sockets *are* allowed. But that's it. Assume that you will NOT be tested for knowledge of the Socket API.

Page 12 of 28

Sample Questions
Colin O'Toole Questions (posted May 23, 2003 09:48 AM)
CQ1. Which of the following statements about business methods in a bean class is incorrect [choose 1]: A. The signature requirements for business methods are always the same for both session and entity beans. B. The argument and return types must always be legal types for the Java RMI API. C. The throws clause may include any exceptions defined by your application. D. A business method should always throw the javax.ejb.EJBException to indicate a system-level problem. CQ2. Which of the following statements about Home methods in a bean class is incorrect for Container Managed Persistence [choose 1]: A: The method must not access relationships. B. The throws clause of the method may include the java.rmi.RemoteException. C. The method must not access the bean's persistence state. D. The method cannot be declared static. E. The throws clause may include any exceptions defined by your application. CQ3. Which of the following are requirements for a message-driven bean [choose 4]: A. It implements the MessageListener and MessageDrivenBean interfaces. B. It implements one or more ejbCreate methods. C. It implements one onMessageReceived method. D. It must not define the finalize method. E. It implements one ejbRemove method. F. It must not have a remote or local interface. CQ4. With CMP, the primary key for an entity bean may be automatically generated by the container if the entity bean meets certain requirements. Which of the following is true [choose 1]? A. In the deployment descriptor, the primary key class must be defined as a java.lang.Object. The primary key field must not specified. B. In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object C. In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object. D. All of the above are requirements. E. None of the above are requirements. Answer: CQ1-B, CQ2-B, CQ3-A, D, E, F CQ4. D

Sh yh’s Questions (posted June 05, 2003 02:08 PM)
SQ1. Which are true about session beans? A. A client can pass a remote home object reference to another application. B. The javax.ejb.EJBMetaData interface is intended to allow application assembly tools to discover information about the session bean, and to allow loose client/server binding and client-side scripting. C. The javax.ejb.EJBLocalHome interface defines the method create() which returns javax.ejb.EJBLocalObject. D. The javax.ejb.EJBLocalHome interface defines the method remove(Object primaryKey) which returns null. SQ2. Consider the following session bean class:

Page 13 of 28

import javax.ejb.*; import javax.naming.*; import javax.sql.*; import javax.jms.*; public class MySessionBean implements SessionBean { private SessionContext sessionContext; private Context jndiContext; private Queue queue; private UserDefinedClass userDefinedClass; public void ejbCreate() { try { queue = (Queue) jndiContext.lookup("java:comp/env/jms/StockQueue"); } catch (NamingException ne) { throw new EJBException(ne); } userDefinedClass = new UserDefinedClass(); } public void ejbRemove() {...} public void ejbActivate() {...} public void ejbPassivate() {...} public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; try { jndiContext = new InitialContext(); } catch (NamingException ne) { throw new EJBException(ne); } } public class UserDefinedClass { String dummy; private DataSource dataSource; public UserDefinedClass() { try { dataSource = (DataSource) jndiContext.lookup( "java:comp/env/jdbc/MyDB"); } catch (NamingException ne) { throw new EJBException(ne); } } } } Which of the following are true about the conversational state? A. The state of the variable sessionContext is kept after passivation/activation. B. The state of the variable jndiContext is kept after passivation/activation. C. The state of the variable queue is kept after passivation/activation. D. The state of the variable userDefinedClass is kept after passivation/activation. E. The container must be able to properly save and restore the reference to the home and component interfaces of the EJBs stored in the instance¡¦s state even if the classes that implement the object references are not serializable.

Page 14 of 28

F. The container may use the object replacement technique (java.io.ObjectOutputStream/ObjectInputStream) to externalize the home and component references. SQ3. Which are true about session beans? (Choose all that apply) A. An attempt to remove a session object while the object is in a transaction will cause the container to throw the IllegalStateException to the client. B. A session bean class must not implement the session bean's component interface. C. A session bean class must not implement the ejbCreate() method. D. The business methods of a session bean must not be declared as final or static. E. The remote interface methods must not expose the managed collection classes that are used for CMP entity beans as arguments or results. SQ4. Given a CMP entity bean, which of the following statements are correct? (Choose all that apply) A. All the exceptions defined in the throws clause of the method of the remote interface must be defined in the throws clause of the matching method of the enterprise Bean class. B. The ejbSelect<METHOD>(...) must not be declared as static or abstract. C. The ejbHome<METHOD>(...) can be declared as final. D. The return value type of a business method of an entity bean class could be of MyClass defined as follows: public class MyClass { public int result; public int getResult() { return result; } public void setResult(int result) { this.result = result; } } E. The throws clause of an ejbPostCreate<METHOD>(...) may define arbitrary application specific exceptions including javax.ejb.CreateException. F. The bean provider must always define a query for each finder method in the deployment descriptor. SQ5. Which of these is/are correct about exception? (Choose all that apply) A. When a RemoveException is thrown from the ejbRemove() method of an entity bean where the corresponding remove() method has CMT attribute Mandatory, the client will receive this RemoveException. B. If the Container denies a client access to a business method, the client will receive RemoteException or EJBException. C. When a NoSuchObjectException is thrown from an ejbHome<METHOD>(...) method of an entity bean where the corresponding home method has CMT attribute RequiresNew, the client's transaction if any must be marked for rollback.

Page 15 of 28

D. When a system exception is thrown from the onMessage() method of a MDB with BMT, any transaction that has been started, but not yet completed, by the instance must be marked for rollback. Answer: A, B, D

For option A: RemoveException is application exception, ejbRemove() runs in the context of the caller's transaction, so container will re-throw the exception to the client, thus client can receive RemoveException. For option B: Although ejbRemove() runs with unspecified transaction context, but client can still receive RemoveException. For option C: NoSuchObjectException is system exception, only container-started transaction will be rollbacked, the client transaction may or may not be marked for rollback. For option D: when system exception is generated from MDB's bean method with BMT, the container will log the exception and mark for a rollback a transaction has been started, but not yet completed, and discard the instance.
SQ6. Which are true about EJB environment? (Choose all that apply) A. A resource manager connection factory reference is scoped to the EJB whose declaration contains the resource-ref element. B. By default, connections to a resource manager are shareable across other EJBs in the application that use the same resource in the same transaction context. C. The Deployer must ensure that all the declared resource environment references are bound to administered objects that exist in the operational environment. The Deployer may use, for example, the JNDI LinkRef mechanism to create a symbolic link to the actual JNDI name of the target object. D. The Deployer should be able to customize an EJB's business logic. SQ7. Which is/are true about security responsibilities? (Choose all that apply) A. The Deployer is responsible for configuring principal mapping for inter-EJB calls. The management of caller principals passed on inter-EJB invocations is set up by the Deployer and System Administrator. B. Security roles are defined by the Bean Provider in the deployment descriptor. C. The EJB Container can, but is not required to, provide support for multiple security domains, and/or multiple principal realms. D. If the client is in a different security domain than the target enterprise bean, the system administrator is responsible for mapping the principals used by the client to the principals defined for the enterprise bean. SQ8. Which is/are true about ejb security? (Choose all that apply) A. If the security infrastructure performs principal mapping, the getCallerPrincipal() method must return the original caller principal. B. If the run-as security identity is set up for the bean, its method getCallerPrincipal() returns the principal that corresponds to the run-as security identity. C. If transactional requests within a single transaction arrive from multiple clients, all requests within the same transaction must be allowed to be associated with different security context.

Page 16 of 28

D. The Container must allow multiple-deployed enterprise beans to co-exist at runtime. ============================ Andrew Perepelytsya – 1 (posted May 23, 2003 07:00 AM) APQ1. Given a database table: code: EmpID 101 102 103 104 Salary 40000 22000 25000 60000 FirstName 'George' 'Sally' 'Bob' 'Julie' LastName 'Smith' 'Jones' 'Smythe' 'Rodriguez' Gender 'M' 'F' 'M' 'F' DepartmentID 'SUP' 'PLN' 'MRK' 'IT'

Employee has a 1:1 unidirectional relationship with department. What would be the correct EJB-QL query for the following finder method? (select one): java.util.Collection findSalaryInDepartment(int minSalary, DepartmentLocal dep) throws FinderException; A. == SELECT emp.salary FROM Employee AS emp WHERE emp.salary > ?1 AND emp.department = ?2 B. == SELECT emp.salary FROM Employee AS emp WHERE emp.salary > ?1 AND emp.departmentID = ?2 C == SELECT DISTINCT emp.salary FROM Employee AS emp WHERE ?1 < emp.salary AND ?2 = department D == SELECT DISTINCT emp.salary FROM Employee AS emp WHERE ?1 < emp.salary AND ?2 = departmentID E == These are not valid finder queries. Which two must be included in every ejb-jar file? (Choose two.) a). Stubs for the EJBHome and EJBObject interface. b). The JAR Manifest file. c). A deployment descriptor. d). The JNDI context. e). The EJB's home interface. Answer: e Kathy – 1 (posted May 19, 2003 11:11 PM) KQ1. Given this code in a stateful session bean business method:

Page 17 of 28

try { Socket s = new Socket(x,y); } catch (Exception ex) { ex.printStackTrace(); } And assuming that x and y are the port and IP address of a running service running on the same server, what is the result? (Assume all other bean code is correct and legal.) A) Compilation fails B) Deployment fails C) An exception is thrown at runtime D) Code compiles, deploys, and runs E) Indeterminate. The code may deploy, but is not guaranteed to be portable to all EJB 2.0 containers. [Hint:

Look in section 24.1.2 of the spec]

Answer: So, what is this question looking for? Your knowledge of the programming restrictions. You'll see other questions testing your knowledge of what is and isn't allowed. But rather than simply asking: Is <some thing> allowed? The questions will offer scenarios or code examples. Don't panic that this question assumes knowledge of the Socket API -- I figure you all know it (or can look it up); rest assured that the real exam will not include questions that require API knowledge about things unrelated to J2EE, unless it has been covered in the SCJP exam. (So, I might take a few liberties with my mock exam questions, that wouldn't be on the *real* exam. I'll let you know if and when I do that.) Look in section 24.1.2 of the spec Kathy – 2 (posted May 25, 2003 10:27 PM) KQ2. Which two are guaranteed to be restored to their pre-passivated state when a passivated stateful session bean is activated with an ejbActivate() call? (Choose two.) A) A reference to a non-serializable SessionContext object. B) A reference to a UserTransaction object. C) A transient reference variable. D) A JDBC connection. [hint: look in section 7.4 of the spec] Answer: KQ1. D KQ2. A, B. Since the container is *required* to successfully passivate/activate a SessionContext reference, even if the reference is to a non-serializable object. Kathy – 3 (posted May 25, 2003 05:38 PM) KQ3. Match the operation in list ONE with the method in list TWO in which that operation can be performed, for a stateful session bean: LIST ONE: Operations (things you want to do) 1) invoke the SessionContext.setRollbackOnly() 2) invoke the UserTransaction.setRollbackOnly() 3) access this bean's own EJBObject interface 4) access this bean's own home interface 5) access a reference to another EJB LIST TWO: Bean methods in which the operations from list one can be performed: A) ejbCreate B) afterBegin

Page 18 of 28

C) business method D) setSessionContext E) afterCompletion Note: There *may* be more than one correct answer! Answer By Andrew:

1. J) client invokes create on the home 2. I) bean constructor invoked 3. H) setSessionContext invoked on the bean 4. B) ejbCreate invoked on the bean 5. A) Client invokes a business method 6. E) afterBegin is called 7. G) business method invoked on the bean 8. F) beforeCompletion is called 9. C) transaction committed 10.D) afterCompletion is called
KQ4. In what order will the following events in a stateful session bean's lifecycle occur? Assume the client already has a reference to a bean's home object, and needs to invoke a business method on a bean. (place a number next to each one) A) Client invokes a business method B) ejbCreate invoked on the bean C) transaction committed D) afterCompletion is called E) afterBegin is called F) beforeCompletion is called G) business method invoked on the bean H) setSessionContext invoked on the bean I) bean constructor invoked J) client invokes create on the home Kathy – 3 (posted May 28, 2003 10:46 AM) KQ5. Here is an example of the way transaction attribute questions appear on the exam:

Assume that the image describes method invocations and shows the transaction context in which each of the methods will run. Assuming that all methods run without exception, which of the following shows transaction attributes that will produce this scenario? (In the diagram, a ___ indicates that there is no transactional context for the method) Answer options: A) Method R - RequiresNew Method S - Supports Method T - Required Method U - NotSupported Method V - Supports

Page 19 of 28

B) Method R - Mandatory Method S - Required Method T - Mandatory Method U - NotSupported Method V - Never C) Method R - RequiresNew Method S - Mandatory Method T - Supports Method U - Never Method V - NotSupported D) Method R - RequiresNew Method S - Mandatory Method T - Required Method U - Supports Method V - Supports Kathy – 4 (posted May 22, 2003 11:18 PM) KQ6. Which two are true about message-driven beans? (Choose two.) A) Message-driven beans do not expose a client view. B) Message-driven beans must implement the JMSListener interface. C) Message-driven beans cannot throw application exceptions. D) Message-driven beans must not use bean-managed transaction demarcation. E) Message-driven beans can use the getCallerPrincipal() method of MessageDrivenContext. ==================================== KQ6B. Which transaction attributes can be specified for a message-driven bean? (Check all that apply, from none to all) A) Required B) RequiresNew C) Supports D) NotSupported E) Mandatory F) Never Kathy – 5 (posted May 25, 2003 10:27 PM) KQ7: Which three are true about transactions in EJB? (Choose three.) A) EJB 2.0 supports nested transactions. B) EJB 2.0 allows you to specify isolation levels. C) Message-driven beans must not use bean-managed transaction demarcation. D) Entity beans must not use bean-managed transaction demarcation. E) Stateful session bean state will not be rolled back if the transaction rolls back. F) Stateful session beans that start a transaction must complete the transaction before ending a business method. G) A message-driven bean must commit or rollback a transaction before onMessage returns. KQ8: Which two are true about bean-managed transaction demarcation? A) A transaction used by a BMT bean MUST have been started by the bean. B) The caller's transaction will be propagated into a BMT bean. C) Transactions in a BMT bean do not propagate when the BMT bean calls a method on another bean. D) A bean cannot use both CMT and BMT together. E) BMT beans must not specify transaction attributes. Answer: KQ7. D, E, G KQ8. D, E

Page 20 of 28

Kathy – 5 (posted May 22, 2003 12:23 PM) as answer KQ9. "Which three types of methods are you required to implement in a Session Bean?" Answer: 1) Methods of the SessionBean interface (which your bean must implement) 2) Business methods from your COMPONENT INTERFACE. (all business methods defined in your component interface must be implemented. Otherwise, the poor client will call x.doReallyImportantStuff() and when the container gets the call, it (the container) will completely freak out because your bean class can't do it!) (yes, most deploytools will stop you from getting that far, but there's no guarantee...) 3) ejbCreate methods from your HOME INTERFACE (a matching ejbCreate for every create in your home) KQ10. "What does ejbPassivate mean to a SessionBean and to an EntityBean?" Answer: "For a SessionBean, it means the bean MUST be stateful, and is about to be... passivated, which means taken out of RAM to preserve resources while we wait for the client to make up his mind and add something else to the shopping cart... at which time the container will say, "Whoa! Somebody's calling a business method again; I better get this bean re-activated. Remember: stateless beans are NOT passivated. They just go back to the pool, so they are not consuming any resources on behalf of a client EXCEPT when the client is in the middle of a business method invocation on the bean." "For an EntityBean, it means the bean is going to be put back into the pool, losing his identity as a particular entity. In other words, his 'state' will be *erased* as he slides back to the pool without a care in the world... and no primary key... ready to sip umbrella drinks and cavort with the other beans in the deep end until the container realizes that , 'Hey, somebody is trying to access Gus T. with a primary key of 42, so we better pull a bean out so that it can *become* Gus T.' at which time, the bean will be reactivated." Bert – 1(posted May 28, 2003 12:16 AM) BQ1. Which two are guaranteed capabilities of EJB 2.0? a). Local home interfaces for messages driven beans. b). Dirty detection mechanisms to reduce memory footprints. c). Run-as security identity functionality. d). The JDBC 2.0 extension. e). Read only CMP entity beans. BQ2. Which API is NOT guaranteed to be supported by EJB 2.0 containers? a). JAXP b). JNDI c). JXTA d). JDBC e). JMS BQ3. When programming business methods, which technique should be avoided to ensure bean portability across all EJB 2.0 containers? a). Using the java.net.Socket class. b). Using inner classes. c). Using the 'final' modifier for fields. d). Passing 'this' as an argument. BQ4. Which two are typically responsible for creating ejb-jar files? (Choose two.)

Page 21 of 28

a). The bean provider. b). The application assembler. c). The deployer. d). The system administrator. BQ5. Which two must be included in every ejb-jar file? (Choose two.) a). Stubs for the EJBHome and EJBObject interface. b). The JAR Manifest file. c). A deployment descriptor. d). The JNDI context. e). The EJB's home interface. Answer: BQ1. C, D BQ2. C BQ3. D BQ4. A, B BQ5. C, E

BQ6. Which statement about session beans is true? a). The bean provider must write the method public void remove() in both stateless and stateful session classes. b). Local clients can remove session beans by calling a method on the bean's home. c). The << remove >> method in the component interface can be used only by remote clients. d). To ask the EJBHome to remove a session bean, the client must provide the bean's handle. Answer: d revision: 2c was << ejbRemove >> BQ7. Which statement about locating or using a session bean's home interface is true? a). Acquiring an 'InitialContext' is required only for remote clients. b). The 'InitialContext' must be narrowed before it can be used. c). Once acquired by a client, a home interface can be used multiple times. d). The client can acquire a handle for the bean's local home interface. Answer: c BQ8. When comparing two session objects, what is true? (Choose all that apply.) a). Using the 'isIdentical' method, stateless session beans from the same home will always return true. b). Using the 'isIdentical' method, stateful session beans from the same home will always return true. c). The 'isIdentical' method can be used only for remote object references. d). Using the 'equals' method, stateless session beans from the same home will always return true. e). Using the 'equals' method, stateful session beans from the same home will always return true. Answer: a BQ9. Which method can be called << without exception >>, by both remote and local clients on a reference to a session bean's component interface?

Page 22 of 28

a). ejbCreate b). getSessionContext c). getPrimaryKey d). getEJBHome e). remove Answer: e revision: added 'without exception' BQ10. Which are directly invoked by the client? (Choose all that apply.) a). ejbPassivate b). business methods c). setSessionContext d). newInstance e). create Answer: b, e

BQ11. Which is true about passivation for stateful session beans? a). The container can passivate a stateful session bean regardless of the bean's << transactional >> state. b). The client can passivate a session bean. c). References to JNDI contexts are lost during passivation. d). References to 'SessionContext' are preserved during passivation. e). A passivated, stateful session bean instance will always be re-activated prior to removal. Answer: d revision: 3.2.a - added << transactional >> BQ12. Match the methods on the left with the interfaces in which those methods can be found, on the right. A match is correct if the method is either declared in, or inherited by, the interface. Note: There may be some many-to-one and one-to-many relationships in your answer.
code:

a). b). c). d). e). f).

afterCompletion getUserTransaction afterBegin isCallerInRole getRollbackOnly setSessionContext <<

1. 2. 3. 4.

SessionSynchronization SessionContext SessionBean UserTransaction

g). setRollbackOnly

new method !!!!!!! >>

Answers: a-1 b-2 c-1 d-2

Page 23 of 28

e-2 f-3 << answer for new method g - 2,4 >> revision: added a new method BQ13. Which statements about stateful and stateless session beans are true? (Choose all that apply.) a). Only stateful session beans support transactions. b). Only stateful session beans can be passivated. c). Only stateful session beans have a 'setSessionContext' method. d). Both stateful and stateless session beans can support overloaded 'ejbCreate' methods. e). Both stateful and stateless session beans can implement the 'javax.ejb.SessionSynchronization' interface. f). Both stateful and stateless session beans can have instance variable state. Answer: b, f BQ14. Which statements about a session bean class are true? (Choose all that apply.) a). They can be marked 'final' b). They can support overloaded constructors. c). Their business methods can be 'private'. d). Their business method names must start with "ejb". e). Their 'ejbCreate' methods must not be declared as 'final'. Answer: e BQ15. For this drag and drop type question, you can use each element only once. Which interface should be matched with which fact, so that all four matches are correct?
code:

1. remote component 2. remote home 3. local component 'java.rmi.RemoteException' 4. local home

a. does not have a getHomeHandle() method b. extends 'javax.ejb.EJBObject' c. methods must NOT throw

d. can be used to retrieve an EJBObject reference.

Answers: 1 2 3 4 b d a c

Page 24 of 28

BQ16. Which two are true about container managed transactions in EJB 2.0? (Choose all that apply.) a). Differentiating between overloaded methods is possible in the bean's deployment descriptor. b). A transactional attribute must be individually declared in the method-name tag, for every business method in the bean class. c). The container will interpose only on method invocations with container-managed transaction demarcation. d). If an 'onMessage' method returns before committing a transaction the container will throw an exception. e). A message-driven bean with CMT demarcation must not invoke the EJBContext.getUserTransaction method. Answers: a, e BQ17. When a business method in an entity bean calls the getRollbackOnly method, which transaction attribute settings will cause the container to throw an exception? (Choose all that apply.) a). NotSupported b). Required c). Supports d). RequiresNew e). Mandatory f). Never Answers: a, c, f BQ18. When a session bean has container-managed demarcation value of 'Supports', which << three >> methods run in an unspecified transaction context? (Choose << three >>.) a). ejbActivate b). getRollbackOnly c). getUserTransaction d). ejbRemove e). afterBegin f). afterCompletion Answers: a, d, f revision: changed 'two' to 'three'
Ashik’s Questions AQ1. Find out two true statements from the following. A) Rearly used data should be represented as entity bean. B) Session beans should be used for transaction controlled business logic. C) Session Beans are good for logic that's shared outside of the limited context of a single application. D) It's a good practice to put business logic into data objects. E) Stateful session beans may serve many clients during their lifetime. F) Entity beans may not have a unique property.

Page 25 of 28

Answer: B, C AQ2. Performance tuning of the whole EJB system is the responsibility of -

A) Bean Provider B) Tool Vendor C) Application Assembler D) EJB Deployer E) System Administrator F) Container and Server Provider
Answer: D AQ3. Find out two false statements from the following.

A) A message-driven bean is decoupled from any client that sends message to it. B) Message-driven beans do not hold conversational state or in other words MDBs are stateless. C) Message-driven beans can be both durable or nondurable subscribers. D) Message-driven beans may not send exceptions back to teh client. E) Message-driven beans do not have any home, local home or local interfaces but only remote interface. F) Message-driven beans may be single-threaded or multi-threaded.
Answer: E, F. John King (posted June 01, 2003 07:06 PM)

JK1. Which of the following EJB Transaction Attributes ensures that the method call always takes place in a transaction, either client started, or container started? a TX_SUPPORTS b TX_MANDATORY c TX_REQUIRED d TX_REQUIRES_NEW
Answer: C, D

Gang Zhang (posted June 05, 2003 02:11 PM) GZ1. Which methods can't have transaction attribute (Choose all apply) 1. 2. 3. 4. 5. onMessage() for MDB remove() for session bean's javax.ejb.EJBObject business method defined in session bean's component interface. method defined in session bean's home interface. method defined in super interface of entity bean's component interface.

Answer: 4

S. Palanigounder (posted June 03, 2003 01:49 PM) SPQ1. While of the following can be included in the conversational state of stateful session beans: (choose four)

Page 26 of 28

1 2 3 4 5 6

SessionContext EJBContex Transient variables Handle EJBHome EJBObject

Answer:

SPQ2. When a client closes a connection obtained from the connection pool, which of the following occurs? 1. 2. 3. 4. The connection is permanently closed The connection is never closed - simply returned to the pool The connection is closed, but reopened and returned to the pool Impossible to tell for sure with the given information

Answer: 2

ZheMin Lin’s Question (posted June 04, 2003 01:29 AM) Which one can be defined as an application exception? A.EJBException B.IOException C.RemoteException D.NoSuchObjectException
Answer: B

Alex Pisarev’s Question (posted May 28, 2003 07:17 AM) APQ1. We have a Stateless Session Bean defined and minimum/maximum pool size variables in the container is set to 1. Which of the two is true? 1) The bean instance could be used as a Singleton - each time we request a new bean we will get the same instance. 2) The bean instance can't be used as a Singleton - the EJB spec does not guarantee that the pool will not be cleared and bean instance re-created at some stage.
Answer: B

Page 27 of 28

Page 28 of 28

Sign up to vote on this title
UsefulNot useful