wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubts in JavaBeat question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubts in JavaBeat question" Watch "Doubts in JavaBeat question" New topic
Author

Doubts in JavaBeat question

krishna bulusu
Ranch Hand

Joined: Aug 28, 2006
Posts: 185
Hi,
Following is the question from javabeat

1:Which of the following statements are true about Session Beans?
a. The method designated with @PreDestroy won't be called by the Container when a
business method throws a System Exception.
b. The life-cycle method PostConstruct, PreDestroy, PostActivation and PrePassivation
are called only once for a Stateful Session Bean.
c. A Stateless Session Bean won't participate in Activation and Passivation Mechanism.
d. A Stateful Session Bean may participate in Activation and Passivation Mechanism.
e. All the above.
The Java Beat Ans is : e
Is it true that the passivation and activation occurs only one time during the life of a sateful sessionbean?

2:Imagine that you have a business interface by name 'Template'. Which of the
following ways can be used by the Client Application to acquire a reference to the
business interface (assuming that this interface is bound in the JNDI Context)?
a. @Resource
SessionContext context;

Template template = (Template)context.lookup("template");
b. @EJB
Template template;
c. Template template = null;
InitialContext context = new InitialContext();
template = (Template)Context.lookup("java:comp/ejb/template");
d. All the above.
TheJavabeat Ans
My Answer: b&c

3:Which of the following statements are true about Local and Remote client
views?
a. The arguments specified by a Remote client to an enterprise bean are passed
through reference.
b. For an enterprise Bean, a local client cannot be a Java Servlet.
c. A Remote Client can run in the same JVM as that of an EJB Container or in a
different JVM.
d. All the above.
The JavaBeat Ans: a,c
My Ans: c

Please tell me if I am wrong.


Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Hi krishna,

Originally posted by krishna bulusu:
1:Which of the following statements are true about Session Beans?
a. The method designated with @PreDestroy won't be called by the Container when a business method throws a System Exception.
b. The life-cycle method PostConstruct, PreDestroy, PostActivation and PrePassivation are called only once for a Stateful Session Bean.
c. A Stateless Session Bean won't participate in Activation and Passivation Mechanism.
d. A Stateful Session Bean may participate in Activation and Passivation Mechanism.
e. All the above.
The Java Beat Ans is : e
Is it true that the passivation and activation occurs only one time during the life of a sateful sessionbean?


I think you are right, passivation and activation may occur any number of times during the life of a stateful session bean.
A quote form the section 4.4 of the ejb core specification:

The container's caching algorithm may decide that the bean should be evicted from memory. (This could happen at the end of each method, or by using an LRU policy).

Note the "at the end of each method".


Originally posted by krishna bulusu:
2:Imagine that you have a business interface by name 'Template'. Which of the following ways can be used by the Client Application to acquire a reference to the business interface (assuming that this interface is bound in the JNDI Context)?
a. @Resource
SessionContext context;

Template template = (Template)context.lookup("template");
b. @EJB
Template template;
c. Template template = null;
InitialContext context = new InitialContext();
template = (Template)Context.lookup("java:comp/ejb/template");
d. All the above.
TheJavabeat Ans: d
My Answer: b&c


The answer to this question depends on which kind of client application we are talking about. Supposing any kind of client (servlet, other ejb, stand alone in ACC, etc.), the three of them may be correct.
However, everything depends on how the business interface has been named in the JNDI. In the first case the bean's interface has been named "template" and in the third one "ejb/template".


Originally posted by krishna bulusu:
3:Which of the following statements are true about Local and Remote client
views?
a. The arguments specified by a Remote client to an enterprise bean are passed through reference.
b. For an enterprise Bean, a local client cannot be a Java Servlet.
c. A Remote Client can run in the same JVM as that of an EJB Container or in a
different JVM.
d. All the above.
The JavaBeat Ans: a,c
My Ans: c


I agree with you. The arguments specified by a Remote client to an enterprise bean are passed through value.
[ September 04, 2008: Message edited by: Sergio Tridente ]

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
krishna bulusu
Ranch Hand

Joined: Aug 28, 2006
Posts: 185
Hi Sergio Tridente,

Thank you very much for your reply
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Doubts in JavaBeat question