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

Some quick questions

 
Colin O'Toole
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Just some quick ones, please be nice when replying
Well it's the end of the day here in Ireland. Now I'm off to paint my new house for the weekend - no study for me
cheers
Colin.
1. Which of the following statements about business methods in a bean class is incorrect [choose 1]:
A. The signature requirements for business methods are always the same for both session and entity beans.
B. The argument and return types must always be legal types for the Java RMI API.
C. The throws clause may include any exceptions defined by your application.
D. A business method should always throw the javax.ejb.EJBException to indicate a system-level problem.
2. Which of the following statements about Home methods in a bean class is incorrect for Container Managed Persistence [choose 1]:
A: The method must not access relationships.
B. The throws clause of the method may include the java.rmi.RemoteException.
C. The method must not access the bean's persistence state.
D. The method cannot be declared static.
E. The throws clause may include any exceptions defined by your application.
3. Which of the following are requirements for a message-driven bean [choose 4]:
A. It implements the MessageListener and MessageDrivenBean interfaces.
B. It implements one or more ejbCreate methods.
C. It implements one onMessageReceived method.
D. It must not define the finalize method.
E. It implements one ejbRemove method.
F. It must not have a remote or local interface.
4. With CMP, the primary key for an entity bean may be automatically generated by the container if the entity bean meets certain requirements. Which of the following is true [choose 1]?
A. In the deployment descriptor, the primary key class must be defined as a java.lang.Object. The primary key field must not specified.
B. In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object
C. In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
D. All of the above are requirements.
E. None of the above are requirements.
 
Ashish Sarin
author
Ranch Hand
Posts: 444
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ans1) B This statement is valid only when the remote access is provided.
Ans2) B is correct
No comments on the other 2 questions hehe
 
Andrew Perepelytsya
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I see nobody wants to answer

3. Which of the following are requirements for a message-driven bean [choose 4]:
A. It implements the MessageListener and MessageDrivenBean interfaces.
B. It implements one or more ejbCreate methods.
C. It implements one onMessageReceived method.
D. It must not define the finalize method.
E. It implements one ejbRemove method.
F. It must not have a remote or local interface.

A, D, E, F.
B - only one no-param ejbCreate() is allowed (same as for Stateless Session Bean, btw);
C - the method name is actually onMessage (defined in MessageListener interface);


4. With CMP, the primary key for an entity bean may be automatically generated by the container if the entity bean meets certain requirements. Which of the following is true [choose 1]?
A. In the deployment descriptor, the primary key class must be defined as a java.lang.Object. The primary key field must not specified.
B. In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object
C. In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
D. All of the above are requirements.
E. None of the above are requirements.

D - but care should be taken by the Bean Provider not to rely on the actual type of the primary key in her code.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew/Ashish/All,
This is what i feel about Question 2. Please comment.
2. Which of the following statements about Home methods in a bean class is incorrect for Container Managed Persistence [choose 1]:
A: The method must not access relationships.
False.
CMR fields can be accessed from within a ejbHome<METHOD> method and hence this has to be the correct answer.
B. The throws clause of the method may include the java.rmi.RemoteException.
(True in case of remote home methods, hence not a correct answer)
C. The method must not access the bean's persistence state.
(True, the home method even if it's defined in a entity bean, the container cannot attach any identity to the bean and hence accessing a beans's persistence state w'd not result in anything.Home methods are accessed via the Home interface and not the bean)
Not correct answer.
D. The method cannot be declared static.
(True, hence not a correct answer)
E. The throws clause may include any exceptions defined by your application.
(True, hence not a correct answer)
 
Andrew Perepelytsya
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karthik, think about the following fact. if the bean cannot access bean's persistent state (no identity available), then how on earth is it possible to access relationship fields?
my understanding always was CMR field were attached to some identified bean.
hence, I think only C is the correct answer for Q 2.
comments?
 
Colin O'Toole
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congrats to Ashish, Andrew, & Karthik!
From my memory the correct answers are
1. B
2. B
3. A D E F
4. D
For question 2, I believe that home methods in a CMP bean class cannot throw the java.rmi.RemoteException exception (note that I'm not talking about method declarations in the home interface). It is late however and I've been painting all day so I'll confirm this tomorrow when I'm more awake.
Thanks all for answering!
Colin.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Perepelytsya:
karthik, think about the following fact. if the bean cannot access bean's persistent state (no identity available), then how on earth is it possible to access relationship fields?
my understanding always was CMR field were attached to some identified bean.
hence, I think only C is the correct answer for Q 2.

I actually interpreted the options in a different way.
>>The method must not access the bean's >>persistence state
by bean's i thought the "current" bean's method.
As for CMRs i thought CMR of any other entity bean since we can get to some other entity bean from within the method.
As for C, again if it's the current bean no, if some other bean then ofcourse yes.
Anyways Colin has given us the correct answer.
home methods in the "bean" cannot throw RemoteExceptions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic