Exercise 1

Question 21 :

Which of the following programs can be created using the ZAC Publish Wizard tool?

A). Installer
B). Deployer
C). Bootstrap
D). Packager
Answer : Option A, Option C

Explanation :

To publish to a WebLogic Server, we can use the ZAC publish wizard. For this, the server must be running, and you will need to know a user and password that has permission to publish. You can also use the ZAC Publish Wizard to create a set of native programs - an installer and a bootstrap - for various operating systems that become part of a published Java application. 
The installer program is a native executable that installs your published Java program on the local machine. It doesn't require a Java environment itself, so it can run out-of-the-box in the native OS. The bootstrap is also a native program; the user runs the bootstrap to invoke the published application. The bootstrap takes care of monitoring for updates, downloading and updating the user's application, and other administrative ZAC functions.

Question 22 :

A stateful session bean implementing the SessionSynchronization interface is deployed on the WebLogic server. Which of the following callback methods may be invoked on the bean?

A). beforeBegin
B). afterBegin
C). beforeCompletion
D). afterCompletion
Answer : Option B, Option C, Option D

Explanation :

A stateful session bean using container-managed transactions can implement the javax.ejb.SessionSynchronization interface to provide transaction synchronization notifications. This interface defines only 3 methods - afterBegin(), beforeCompletion() and afterCompletion(). 
The afterBegin() callback method is called when the bean becomes part of a transaction. It is called before the EJB Object delegates the business method invocation to the bean instance. If the transaction is committed, the bean will be notified through its beforeCompletion() method. If the transaction is rolled back, this method is not invoked. The afterCompletion() method is always invoked whether the transaction ended with a commit or a rollback. A is incorrect because beforeBegin is not a method defined in the SessionSynchronization interface.

Question 23 :

The home of a Product CMP entity bean has a finder method, which returns an Enumeration of all the products whose price falls below a certain value, which is passed as the method argument. If there are no products in the database to match the above criteria what will be the result of a call to this finder method?

A). EJBException is thrown
B). ObjectNotFoundException is thrown
C). NoSuchEntityException is thrown
D). An empty enumeration is returned
Answer : Option D

Explanation :

Find methods that return a single remote reference throw a FinderException if an application error occurs and a ObjectNotFoundException if a matching bean cannot be found. The ObjectNotFoundException is a subtype of FinderException and is only thrown by find methods, which return single remote references. 
The findByPrimaryKey() method returns only one remote reference since there is a one-to-one relationship between a primary key's value and an entity. Find methods that return an Enumeration or Collection type return an empty collection or enumeration if no matching beans can be found or throw a FinderException if an application error occurs. NoSuchEntityException is a system exception thrown by the ejbLoad() method of an entity bean when the database row to be loaded is not found and also by the ejbStore() method when the database row to be updated cannot be found. It is a subclass of EJBException.

Question 24 :

Which is the only method defined in the javax.ejb.Handle interface?

A). getEJBhome
B). getEJBObject
C). getPrimaryKey
D). gethomeHandle
Answer : Option B

Explanation :

The Handle is a serializable reference to the EJBObject. The EJBObject.getHandle() method returns a Handle object. The Handle allows us to recreate an EJB object remote reference that points to the same type of session bean or the same unique bean that the handle came from. 
The Handle interface specifies only one method, getEJBObject(). Calling this method returns the EJB Object from which the handle was created. After getting the object back, we can narrow or cast it to the appropriate remote interface type. The getEJBhome method is defined in the homeHandle interface and the getPrimaryKey method in the Entity Context interface. The gethomeHandle method is defined in the EJBhome interface.

Question 25 :

In CORBA, which of the following files generated by the "idltojava" compiler must be compiled before running the server application?

A). Only The Holder Classes
B). Only The Helper and Holder Classes
C). The implementation class(es) written by the user to provide body to the methods defined in the interface class
D). All idltojava generated files (stubs, skeletons, helper, holder and interface classes)
Answer : Option C, Option D

Explanation :

The Helper class (a final class) provides auxiliary functionality, notably the narrow() method required to cast CORBA object references to their proper types. The Holder class provides operations for out and in out arguments, which CORBA has but which do not map easily to Java's semantics. The server application cannot be compiled successfully until the implementation class(es) has/have been written and compiled. All the other generated files however must be compiled to form '.class' files from the '.java' files. Thus all the implementation classes written by the user and all the "idltojava" generated files must be complied to run the CORBA Server.