• 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

Default Constructor....

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
==========================================================================
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic