Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a mock question

 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
31. Given this code:
try {
Advice a = aHome.create();
Handle aHandle = a.getHandle();
} catch (Exception ex) {...}
which are true? (assume everything compiles and works
A) aHandle must be Serializable.
B) Advice must extend EJBHome
C) The object referenced by aHandle is from a class implemented
the container
D) The Bean Provider implemented the aHome.create() method.
E) getHandle() declares a RemoteException
F) Handle extends java.rmi.Remote
G) The object referenced by 'a' IS-A java.rmi.Remote
 
Dhondiba Joshi
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the answer g ?
 
Mihai Alexe
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A) aHandle must be Serializable.
B) Advice must extend EJBHome
C) The object referenced by aHandle is from a class implemented
the container
D) The Bean Provider implemented the aHome.create() method.
E) getHandle() declares a RemoteException
F) Handle extends java.rmi.Remote
G) The object referenced by 'a' IS-A java.rmi.Remote

A - yes; Handles implement the javax.ejb.Handle interface and that interface extends Serializable [see EJB API specification]

B. no - Advice is an EJB Object reference, therefore it must implement EJBObject, not EJBHome.

D.- no; the bean provider provides only the component interface, i.e. only the create method declaration. The container is responsible for the actual implementation. The create() method here would be implemented in the Session EJBHome class implemented by the container [see spec page 100]

E. yes; since EJBObject implements java.rmi.Remote, every method declaration must contain in RemoteException in the throws clause. In this case: public Handle getHandle()
throws java.rmi.RemoteException

F - no; see API documentation

G. yes; every EJB Object is-a Remote object [i.e. indirectly implements the java.rmi.Remote interface]

C - yes; the deployment tools are responsible for implementing the handle classes for the session bean's remote home and component interfaces [see EJB2.0 spec page 101]
[ August 27, 2005: Message edited by: Mihai Alexe ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic