• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubts in JavaBeat question

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sergio Tridente,

Thank you very much for your reply
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic