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.
========================================================================== 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 ==========================================================================
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.
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).
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop