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

Default Constructor....

 
Vijay Govind
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks

Below is a question and the explanation for the correct answers, from ejbcertificate.com. My confusion is on 5. Why is 5 not right? HFEJB suggesets to leave out the constructor as the compiler will insert the default constructor and hence 5 should be correct. Please suggest.

TIA
Vijay


==========================================================================
Which of the following statements are requirements for the session bean class?
1) The session bean class must implement, directly or indirectly the javax.ejb.SessionBean interface. 2) Each method defined in the session bean class must have a matching method in the session bean's remote interface. 3)The class must be defined as public. 4) The class can be declared final. 5) A stateful session bean class does not have to define a no-argument public constructor.

Answers 1 and 3 are correct.

Answer 2 is incorrect. The session bean class can define other methods such as helper methods for internal uses that are not made available to remote clients. However, each method defined in a session bean's remote interface must be defined in the session bean class.

Answer 3 is incorrect. If the session bean class is declared final, the container will be unable to extend the class should it wish to mix in some container-specific code with the session bean class.

Answer 5 is incorrect because the container uses the no-argument constructor to create instances of the session bean class
==========================================================================
 
John Mathew
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Answers 1 and 3 are correct. answer 5 is incorrect because the bean class should have a public constructor WITH-OUT any arguments.The option 5 says it so. Please look at the option 5 again this way:
5) A stateful session bean class DOES NOT have to define a NO-argument public constructor.

If would be correct if it says, "A stateful session bean class , have to define a NO-argument public constructor.

regards
JohnM
 
Vijay Govind
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks first of all. I somehow was thinking that it is not Bean Provider's responsibility to define a default constructor. I was not thinking about the bean class as such.(i.e after it was compiled & by when it should have got this default constructor).

Thanks anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic