• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

A mock question

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question says:

Which method can be called "without exception", by both remote and local clients on a reference to a session bean's component interface?

A.ejbCreate
B.getSessionContext
C.getPrimaryKey
D.getEJBHome
E.remove

and it says correct answer is E(ie Remove) , I think a remove method can always throw RemoveException ( weather local or Remote doesn't matter). I think correct answer should be getEJBHome(D) as the component stub was created from Home so we can always have eJBHome W/o Exception.. Any thoughts?? Please let me know if I'm wrong..
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please tell us which exam provides this mock question.
 
Narayan R
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question was in the mocks by jPilotExam web site.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
***********************
Which method can be called "without exception", by both remote and local clients on a reference to a session bean's component interface?

A.ejbCreate
B.getSessionContext
C.getPrimaryKey
D.getEJBHome
E.remove
***********************

The Correct answer is E.
Bcz
A=> Container calls this method.
B=> Wrong
C=> Its a Home method.
D=> Applicable only for Remote Component interface.
E=> remove is available for both Local and Remote component interface.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
Please tell us which exam provides this mock question.



There's a red flag if I've ever seen one.

Originally posted by Senthil Gangatharan:
The Correct answer is E.



Almost there but not quite, check the API docs:
EJBObject
EJBLocalObject

EJBObject.remove() throws RemoveException (Checked, Application Exception) and RemoteException (Checked, System Exception)

EJBLocalObject.remove() throws RemoveException (Checked, Application Exception) and EJBException (Unchecked, System Exception)


Now if the question would have asked "without application exception" and on an "Entity Bean" it would be C.

EJBObject.getPrimaryKey() throws RemoteException (Checked, System Exception)
EJBLocalObject.getPrimaryKey() throws EJBException (Unchecked, System Exception)

But of course on a session bean getPrimaryKey() will throw a system exception.

On a "stateless session bean" the answer would be E for the first time that "remove()" is called because the method doesn't do anything. However the second time "remove()" is called a NoSuchObjectException/NoSuchObjectException will be thrown - the question could have sidestepped that one by asking "without application exception".

EJB 2.0 spec page 79.


When the client calls remove on the home or component interface to remove the session object, the container issues ejbRemove() on the bean instance. This ends the life of the session bean instance and the associated session object. Any subsequent attempt by its client to invoke the session object causes the java.rmi.NoSuchObjectException to be thrown if the client is a remote client, or the javax.ejb.NoSuchObjectLocalException if the client is a local client. (The java.rmi.NoSuchObjectException is a subclass of the java.rmi.RemoteException; the javax.ejb.NoSuchObjectLocalException is a subclass of the javax.ejb.EJBException). The ejbRemove() method cannot be called when the instance is participating in a transaction. An attempt to remove a session object while the object is in a transaction will cause the container to throw the javax.ejb.RemoveException to the client. Note that a container can also invoke the ejbRemove() method on the instance without a client call to remove the session object after the lifetime of the EJB object has expired.



On a "stateful session bean" calling "remove()" has the risk of a RemoveException.


Lesson 1.: Mock questions are (mostly) a waste of time - i.e. don't spend too much time on them.

Lesson 2.: If you need mock questions for a warm up at the end of your studies only use them if they come from a reputable source that does the technical research to come up with high quality questions, answers and justifications for the answers.

For example, I know I'm probably going to break down and get Whizlab's SCDJWS simulator because there is no study guide (which would normally provide mock questions) simply because I don't care for taking (and paying for) any exam twice. At the end of my studies I want to know if I've covered all the bases - even though I will loath each 2 hour session that I feel would be better spent doing some more reading, research, coding or testing.
[ October 14, 2005: Message edited by: Peer Reynders ]
 
You've gotta fight it! Don't give in! Read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic