CertCities.com -- The Ultimate Site for Certified IT Professionals
Keep on Top of the Latest Certification News: Subscribe to CertCities.com Newsletter
  Microsoft®
  Cisco®
  Security
  Oracle®
  A+/Network+"
  Linux/Unix
  More Certs
  Newsletters
  Salary Surveys
  Forums
  News
  Exam Reviews
  Tips
  Columns
  Features
  PopQuiz
  RSS Feeds
  Press Releases
  Contributors
  About Us
  Search
 

Advanced Search
  Free Newsletter
  Sign-up for the #1 Weekly IT
Certification News
and Advice.
Subscribe to CertCities.com Free Weekly E-mail Newsletter
CertCities.com

See What's New on
Redmondmag.com!

Cover Story: Secrets of the Windows Gurus

Reader Review: Word 2007 -- Not Exactly a Must-Have

Access Anywhere

Windows Vista: Learning To Play Nice

Product Review: WhatsUp Gold 11.0, Premium Edition


CertCities.com
Let us know what you
think! E-mail us at:



Visit Redmond Media Group
 
 
...Home ... Editorial ... Pop Quiz ..Pop Quiz Article Saturday: November 17, 2007
TechBusiness: Resources for Innovation Through Software Technology on Redmond Developer News
Secure Computing: Visit SWAT Now!
Dice: The Career Hub for Tech Insiders


Sun Certified Business Component Developer for the Java 2 Platform 1.3
Test your server-side component savvy for Sun's new SCBCD exam with these 18 pop quiz questions courtesy of WhizLabs Software.


courtesy of   Whizlabs Software

Questions

1. Consider the following session bean home interface located through the Java Naming and Directory Interface (JNDI).

Context initialContext = new InitialContext();
ProcessPaymentHome ppHome = (ProcessPaymentHome)
initialContext.lookup(“java:comp/env/ejb/pphome”);

Which exceptions must be declared in the signatures of the methods contained in the ProcessPaymentHome interface?

A. RemoteException
B. FindException
C. Any application specific exception
D. CreateException
E. RuntimeException

2. When a stateful session bean is about to be passivated, which of the following can remain assigned to non-transient fields of the session bean class?

A. null
B. A reference to the javax.transaction.Transaction interface.
C. A reference to the javax.ejb.SessionContext object (even if it is not serializable).
D. A JDBC connection.
E. A serializable object whose declared type does not implement the Serializable interface.

 

3. For which of the following enterprise bean types will an ejbCreate method be invoked on an enterprise bean class instance when a client invokes the corresponding create method on the enterprise bean’s home interface?

A. Stateless session bean
B. Message-driven bean
C. Entity bean
D. Stateful session bean

 

4. Consider the following code taken from some enterprise bean class (Assume all reference variables have been declared properly and the code has been compiled successfully):

EJBObject obj = ejbContext.getEJBObject();
Object pkey = obj.getPrimaryKey();

What type of bean may contain such code?

A. Message-driven bean
B. Stateless session bean
C. Entity bean
D. Stateful session bean
E. None of the above

 

5. Which of the following methods must the Bean Provider implement in an entity bean class?

A. ejbFind()
B. setRollbackOnly()
C. unsetEntityContext()
D. ejbSelect()
E. ejbLoad()

 

6. Given the following sequence of method calls:


Method A (transaction A)
|
+-   Method B (no transaction)
|       |
|      + Method C (transaction B)
|
+-   Method D (transaction A)
|
+- Method E (transaction C)
      |
     + Method F (no transaction)

Select all combinations of transaction attributes that would make this scenario possible (without exceptions being thrown).

A. B-Supports, C-Required, D-Supports, E-Required, F-NotSupported
B. B-NotSupported, C-Required, D-Mandatory, E-RequiresNew, F-NotSupported
C. B-NotSupported, C-RequiresNew, D-Required, E-RequiresNew, F-Never
D. B-Never, C-Required, D-Required, E-Mandatory, F-Never
E. B-NotSupported, C-RequiresNew, D-Supports, E-RequiresNew, F-NotSupported
F. B-NotSupported, C-Mandatory, D-Supports, E-RequiresNew, F-NotSupported

 

7. Which of the following is not an application exception?

A. javax.ejb.ObjectNotFoundException
B. java.lang.Exception
C. javax.ejb.CreateException
D. javax.ejb.NoSuchEntityException
E. javax.ejb.FinderException

 

8. Which deployment descriptor element must a Bean Provider use in order to specify that connections obtained from a resource manager connection factory reference are shareable or not?

A.
B.
C.
D.
E.

 

9. Select all correct statements.

A. EJBs are not allowed to open a socket to connect to a FTP server and download a document.
B. EJBs are not allowed to log an error to a file on disk.
C. EJBs are allowed to install a new security manager when they have to perform highly secure jobs.
D. EJBs are allowed to invoke Class.getResource in order to retrieve bundled resources (images, texts, properties, etc).
E. EJBs are allowed to create small java.awt.Window components in order to display business processing errors or exception messages.
F. EJBs are allowed to spawn their own threads in order to perform some time-consuming tasks, for example.

 

10. Select all correct statements that will result in the removal of an entity object.

A. Invoking delete() on the entity bean’s home interface and providing the primary key in argument.
B. Invoking delete() on the entity bean’s component interface and providing the primary key in argument.
C. Invoking remove() on the entity bean’s home interface and providing the primary key in argument.
D. Removing another entity bean that is in a one-to-one or one-to-many container-managed relationship with the entity bean, and the element (in ) is specified for the entity bean.

 

11. What are the requirements for a primary key class that maps to multiple fields of an entity bean class?

A. The primary key class must be private and be an inner class of the entity bean class.
B. The primary key class must be public and abstract as the container will be responsible for providing an implementation of the primary key classes.
C. All fields of the primary key class must follow the JavaBeans conventions, that is, the fields must be private, and public accessor or mutator methods must be provided.
D. All fields of the primary key class must be declared public (and thus, break the encapsulation of the primary key class).
E. Only the container-managed field names of the entity bean declared in the deployment descriptor can be used as field names in the primary key class.

 

12. Select all valid EJB-QL queries listed below.

A.SELECT OBJECT(inv) FROM Invoice inv WHERE inv.amount > 1000
B. SELECT OBJECT(inv) WHERE Invoice inv, inv.quantity <= 10
C. SELECT OBJECT(inv.amount) FROM Invoice inv WHERE inv.quantity >= 10
D. Select object(INV) fRoM Invoice inv WheRE inv.quantity =< 10
E. SELECT DISTINCT(inv) FROM Invoice inv WHERE inv.amount >= 10000

 

13. Given the following onMessage() method of a message-driven bean (Assume that all necessary imports have been made, that Bean is the component interface type of a stateless session bean and BeanHome is its home interface):

public void onMessage(javax.jms.Message msg) {
      Context initCtx = new InitialContext();
      Object result = initCtx.lookup("java:comp/env/ejb/Bean");
      BeanHome beanHome = (BeanHome) PortableRemoteObject.narrow(result,
                                      BeanHome.class);
      //do something with beanHome.

}

Select all the correct statements:

A. The code will not compile. The onMessage() method if a message-driven bean may throw any application exception.
B. The code compiles fines.
C. The code should be enclosed in a try-catch block.
D. The onMessage() method declaration does not satisfy the requirements of the EJB 2.0 specification.

 

14. Select all correct statements about the different deployment descriptor elements that pertain to EJB security management.

A. The Bean Provider defines security roles using the element.
B. The Application Assembler defines security role references using the element.
C. The Bean Provider defines security role references using the element.
D. The Application Assembler defines security roles using the element.
E. The and elements are linked by a element.

 

15. A stateless session bean class is not allowed to declare any instance variable.

A. True
B. False

 

16. What happens if a client invokes the get accessor method for a collection-valued cmr-field that must not contain duplicate values and that has no related values?

A. The method returns null.
B. The method returns an empty java.util.Collection.
C. The method throws an exception.
D. The method returns an empty java.util.Set.
E. None of the above.

 

17. What is the declared type of the unique argument of the setEntityContext() method?

A. javax.ejb.EntityBean
B. javax.ejb.EJBContext
C. javax.ejb.EntityBeanContext
D. javax.ejb.Context
E. javax.ejb.EntityContext

 

18. Which exception would a client receive if a javax.ejb.EJBException is thrown from a business method whose transaction attribute is Mandatory?

A. javax.ejb.EJBException
B. javax.ejb.TransactionRolledbackLocalException
C. javax.transaction.TransactionRequiredException
D. java.rmi.RemoteException
E. javax.transaction.TransactionRolledbackException
F. javax.ejb.TransactionRequiredLocalException

 

Answers:

1) C, D. It is important to note that the object retrieved from JNDI is directly cast to the correct interface type without being narrowed first. This clearly indicates that we are dealing with the local client view of a session bean. This rules out choice A, as RemoteException must only be declared when dealing with remote client views. Choice B is incorrect. Even if the exception called were FinderException, the answer would still be incorrect, as only entity bean home interfaces define finder methods. Choice C is correct. Any application specific exceptions might be thrown from the methods declared in the home interface of a session bean. Choice D is correct since session bean home interface have to declare at least one create method and the throws clause of create methods must include CreateException. Choice E is incorrect since RuntimeException is an unchecked exception and it is not mandatory to declare such exceptions in the throws clause of the methods. Please refer to sections 6.2.1 and 7.10 of the EJB 2.0 specification for further details.

2) A, C, E. Choice A is correct because non-transient member fields are allowed to refer to null and still be serializable.Choice B is incorrect, because there is no such interface called javax.transaction.Transaction. The correct interface name is javax.transaction.UserTransaction.Choice C is correct. Even if the session context object is not serializable, the EJB container must ensure that the SessionContext object will be serialized properly, so that it can be used again when the session bean is activated.Choice D is incorrect because a JDBC connection is not serializable. The Bean Provider must close all JDBC connections and set their references to null in the ejbPassivate() method.
Choice E is correct since the Java Serialization protocol determines dynamically if an object is serializable or not based on its runtime type and not on its declared type. It is worth noting that an EJB container is not required to use the Java Serialization protocol when passivating beans, it is free to use any techniques it deems appropriate. However, the chosen technique must achieve the same result as the Java Serialization protocol. Please refer to section 7.4.1 of the EJB 2.0 specification for further details.

3) C, D. Choices A and B are incorrect. An ejbCreate method is never invoked on a stateless session bean or on a message-driven bean when a client invokes the corresponding create method of the bean’s home interface. A client can still invoke a create method and think it is in charge of the bean’s lifecycle, but that’s not what is happening under the hood. The EJB container is alone responsible for creating new instances of such enterprise beans.Choices C and D are correct. When a client invokes a create method on an entity bean’s home interface or on a stateful session bean’s home interface, the corresponding ejbCreate method is invoked on the enterprise bean’s instance. Please refer to sections 7.6, 7.8, 10.5 and 15.5 of the EJB 2.0 specification for further details.

4) C. Primary keys only make sense for entity beans. As a result, the only possible answer is choice C. Please refer to sections 9.9 and 9.10 of the EJB 2.0 specification for further details.

5) C, E. Choices A and D are incorrect because the ejbFind() and ejbSelect() methods are declared to be abstract in an entity bean class. The Bean Provider only needs to declare them but not to implement them. It is the responsibility of the EJB container to provide an implementation for these methods. Choice B is incorrect since the setRollbackOnly() method is defined in the javax.ejb.EJBContext and javax.transaction.UserTransaction interfaces that must be implemented by the EJB container.Choices C and E are correct. The Bean Provider must implement the unsetEntityContext() and ejbLoad() methods. Note that the former is invoked when the life cycle of the entity bean instance has been terminated by the EJB container. The latter is called when the container needs to synchronize the state of an entity bean instance with the entity object’s persistent state. Please refer to section 10.5.2 of the EJB 2.0 specification for further details.

6) B, E. In order to choose the correct answers, let’s describe what happens:

The method A (in transaction A) invokes the method B. The only way the method B will run in an unspecified transaction context is by specifying the NotSupported transaction attribute. If the transaction attribute of the method B were Supports, then the method B would run in transaction A, and if it were Never, an exception would have been thrown by the EJB container. Hence, Choices A and D can be ruled out.

The method C is invoked by the method B and in order for it to run in transaction B, only the transaction attributes Required or RequiresNew can be specified. This rules out choice F, because an exception would have been thrown by the EJB container since Mandatory requires that a transaction context exists before invoking the method.

When the methods C and B return, the method A invokes the method D. Knowing that the method D runs in the same transaction context as the method A, we can figure out that only the transaction attributes Supports, Required and Mandatory can be used.

When the method D returns, the method A invokes the method E that runs in a new transaction (C). The only way to achieve this is to use the RequiresNew transaction attribute for method E.

Finally, the method E in transaction C invokes the method F that runs in an unspecified transaction context. The only way to suspend the transaction C is to use the NotSupported transaction attribute, as it was the case with method B. If the transaction attribute of method F was Never, an exception would have been thrown by the EJB container, so this choice can be ruled out.

According to what precedes, only choices B and E are correct. Please refer to section 17.6.2 of the EJB 2.0 specification for further details.

7) D. Choices A, C, and E are incorrect because all these exceptions are standard application exceptions defined by the EJB 2.0 specification. Choice B is also incorrect, as java.lang.Exception is the superclass of all application exceptions. Choice D is correct. javax.ejb.NoSuchEntityException is a subclass of the javax.ejb.EJBException, which denotes a system exception. Please refer to sections 10.5.8 and 18.1.1 of the EJB 2.0 specification for further details.

8) C. A Bean Provider may use the in order to specify the shareability of connections obtained from a resource manager connection factory reference. The element can take two possible values, namely, Shareable and Unshareable.All the other choices are incorrect, as those deployment descriptor elements do not exist. Please refer to section 20.4.1.1 of the EJB 2.0 specification for further details.

9) B, D. Choice A is incorrect because EJBs are allowed to be network clients as long as they do not connect to multicast sockets. However, they cannot be network servers, that is, they cannot listen and accept connections by using an instance of the class java.net.ServerSocket.Choice B is correct since EJBs are not allowed to use the java.io package in order to access files and directories in the file system. The EJB container is responsible for logging errors in case something bad happens. Choice C is incorrect because it is not allowed that EJBs create or install their own security manager. This would create potential security hole. Choice D is correct. EJBs are allowed to retrieve resources (images, texts, properties, etc) that have been bundled within the same enterprise application archive. Choice E is incorrect, as it is not admissible for EJBs to use any component or sub-component of the java.awt package. Remember that EJBs are server-side components and that it does not make a lot of sense to use graphical components on the server to display information to the user on the client-side. Choice F is incorrect. EJBs are not allowed to create new threads, or even manage existing ones, as the runtime environment is under the unconditional responsibility of the EJB container. Please refer to section 24.1.2 of the EJB 2.0 specification for further details.

10) C, D. Choices A and B are incorrect since there are no such methods in the EJB(Local)Home and EJB(Local)Object interfaces. Choice C is correct. Invoking the remove() method on an entity bean’s home interface and providing the entity bean’s primary key in argument results in the ejbRemove method to be invoked and in the removal of the persistent representation of the entity bean. Choice D is correct. Given that two entity beans, E1 and E2, are in a one-to-one relationship and that the element has been specified for E2, when E1 is removed, so will E2. This is also true for one-to-many relationships, but not for many-to-many relationships. Please refer to section 10.3.4 of the EJB 2.0 specification for further details.

11) D, E. Choice A is incorrect since the primary key class must be declared public and not private. Choice B is incorrect because the primary key class does not need to be declared abstract. The container should be allowed to use the primary class without having to extend it. Choice C is also incorrect as there is no such requirement. All fields of the primary key class must be declared public, even if this means that the encapsulation of the class is broken. Hence, choice D is correct. Choice E is also correct. The primary key class is not allowed to declare fields having names that are different from the names of the container-managed fields declared in the elements in the deployment descriptor.Please refer to section 10.8 of the EJB 2.0 specification for further details.

12) A, D. Choice A is correct, as the query is well formed and syntactically correct. The query selects all invoices whose amount is bigger than 1000. Choice B is incorrect because the FROM clause is mandatory in any EJB-QL expression. Moreover, all identification variables must be declared in the FROM clause, and not in the WHERE clause. Choice C is incorrect, as the SELECT clause must not use the OBJECT operator to qualify path expressions (inv.amount). Choice D is correct since all keywords of the EJB-QL language as well as all identification variables are case insensitive. This means that one cannot define two identification variables named INV and inv, for instance. Choice E is incorrect, as the DISTINCT keyword is used to remove all duplicate elements from the result set. In order to qualify an identification variable, one must use the OBJECT keyword. Please refer to section 11 of the EJB 2.0 specification for further details.

13) A, D. Choice A is correct. The code does not compile because the lookup method may throw a javax.naming.NamingException, which is a checked exception. Since the EJB 2.0 specification prohibits the onMessage() method to declare any application exception in its throws clause, a try-catch block must be used. Therefore, choice D is also correct. In addition, the narrow() method may throw a java.lang.ClassCastException (unchecked exception) and the EJB 2.0 specification recommends that well-behaved message-driven beans should not throw any RuntimeException. Choices B and C are incorrect for the reasons given above. Choice E is incorrect, as the onMessage() method given in the question statement satisfies the requirements stated in section 15.7.4 of the EJB 2.0 specification. Please refer to sections 15.7.4 and 15.4.10 of the EJB 2.0 specification for further details.

14) C, D. Choices A, B and E are incorrect. The responsibilities of the Bean Provider and Application Assembler roles have been interchanged. The opposite is correct, though. Hence, Choices C and D are correct. The Bean Provider is responsible for defining security role references with the element. These roles are security roles referenced in the code. The Application is responsible for building the application and defining the security roles of the enterprise application using the element. These security roles are logical, as the Application Assembler has no knowledge of the security environment of the operational environment on which the application will be deployed. It is the Application Assembler’s duty to link every security role reference defined by the Bean Provider to security roles defined by him using the element. There is no such element as the element. Therefore, Choice E is incorrect. Please refer to section 21.3.1 and 21.3.3 of the EJB 2.0 specification for further details.

15) B.Stateless session beans do not keep any conversational state between client invocations. This doesn’t mean that a stateless session bean class cannot declare instance variables. However, these instance variables should not be used to store client data. For example, a session bean class usually stores a reference to a SessionContext instance given by the container into an instance variable, but this is not part of the conversational state. Please refer to section 7.8 of the EJB 2.0 specification for further details.

16) D. When a get accessor method for a collection-valued cmr-field that has no related values is invoked, the method must return an empty collection. Since the collection in question must not contain duplicate values, the only possible choice is D. Choice B would be correct if the cmr-field allowed duplicate values. All the other choices are incorrect. Please refer to section 10.3.8 of the EJB 2.0 specification for further details.

17) The only correct choice is E. The setSessionContext() method is defined in the javax.ejb.EntityBean interface and takes one argument of the type javax.ejb.EntityContext. This method is invoked only once and very early in the life cycle of entity beans. It gives the entity bean instance an opportunity to get a reference on the context in which it will be running. All other choices are incorrect. Please refer to section 10.5.2 of the EJB 2.0 specification for further details.

18) B. The difficult thing to do here is to decorticate the information contained in the question statement. First, we know that the bean throws a javax.ejb.EJBException, so we know we are dealing with a local client. Therefore, we can eliminate choices C, D and E right away. Second, since the transaction attribute of the business method is Mandatory, we know for sure that a client transaction existed (otherwise the container would have thrown javax.ejb.TransactionRequiredLocalException) and that choice F is incorrect. When a business method that executes in the context of the local caller’s transaction throws a javax.ejb.EJBException, the EJB container is required to throw javax.ejb.TransactionRolledbackLocalException as mentioned in Table 15 on page 375 of the EJB 2.0 specification. Therefore, choice B is correct. Since the javax.ejb.EJBException is not propagated, choice A is incorrect. Please refer to sections 18.2.2, 18.3.1 and 18.4.2.1 of the EJB 2.0 specification for further details.

 

Questions and answers provided by Whizlabs Software. To order the full version of this exam using WhizLab's simulation software, click here.

For more CertCities.com pop quizzes, click here. To access our list of free, non-braindump practice exams from across the Web, click here.


More Pop Quiz:


There are 3 CertCities.com user Comments for “Sun Certified Business Component Developer for the Java 2 Platform 1.3”
Page 1 of 1
11/13/03: Jenni says: Really cool explanations! Great Job
6/27/06: satyajit kumar from C-DOT , Delhi says: It is Really....Good...stuff.As my Experience most of people even worked in ejb but conceptually lacks are still there.
10/18/06: LamPhong from can tho says: 1)a 2)b 3)c
Your comment about: “Sun Certified Business Component Developer for the Java 2 Platform 1.3”
Name: (optional)
Location: (optional)
E-mail Address: (optional)
Comment:
   

top


Sponsored Links
Work Smarter with Citrix Education
Learn how to maximize the performance of your IT environment
Get 25% Off Certification Practice Exams
Introductory offer at SybexTestsuccess.com through November
Capella U. IT career with a degree online.
Click here to learn about our many specializations



Home | Microsoft® | Cisco® | Oracle® | A+/Network+" | Linux/Unix | MOS | Security | List of Certs
Advertise | Contact Us | Contributors | Features | Forums | News | Pop Quiz | Tips | Press Releases | RSS Feeds RSS Feeds from CertCities.com
Search | Site Map | Redmond Media Group | TechMentor Conferences | Tech Library Webcasts
This Web site is not sponsored by, endorsed by or affiliated with Cisco Systems, Inc., Microsoft Corp., Oracle Corp., The Computing Technology Industry Association, Linus Torvolds, or any other certification or technology vendor. Cisco® and Cisco Systems® are registered trademarks of Cisco Systems, Inc. Microsoft, Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corp. Oracle® is a registered trademark of Oracle Corp. A+®, i-Net+T, Network+T, and Server+T are trademarks and registered trademarks of The Computing Technology Industry Association. (CompTIA). LinuxT is a registered trademark of Linus Torvalds. All other trademarks belong to their respective owners.
Reprints allowed with written permission from the publisher. For more information, e-mail
Application Development Trends | Campus Technology | CertCities.com | The Data Warehousing Institute
E-Gov | EduHound | ENTmag.com | Enterprise Systems | Federal Computer Week | FTPOnline.com | Government Health IT
IT Compliance Institute | MCPmag.com | Recharger | Redmond Developer News | Redmond
Redmond Channel Partner | TCPmag.com | T.H.E. Journal | TechMentor Conferences | Visual Studio Magazine | VSLive!
Copyright 1996-2007 1105 Media, Inc. See our Privacy Policy.
1105 Redmond Media Group