Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Piet Souris

About the empty constructor

Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, Kathy told us 1000000 times that one of the requirements for a bean is to declare an empty constructor...BUT...I remember quite well that more than once we were also suggested not to write this method at all (unless in case of particular reasons) and to leave the constructor to the compiler. Now, I've got on question like the following:

Identify all correct requirements for a CMP entity bean class? [Check all correct answers]

1. The class must be defined as public.
2. The class must define a public constructor that takes no arguments.
3. The class must not be defined as abstract.
4. The class must define the finalize() method.
5. The class must implement, directly or indirectly, the javax.ejb.EntityBean interface.

I replied 1 and 5 (not 2) because I supposed that the entity bean class must NOT define an empty constructor, as the compiler creates one for us. Why this is wrong? (The correct answers were 1,2, 5)
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No 2 is a requirement. So you should have no arg Constructor, but how it got there is not the question. Whether compilers puts it or you write it, it doesn't matter, you should have it.

So you should select 2 as an answer.
Well THAT's new! Comfort me, reliable tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic