Multiple choice java

What isnottrue of a Java bean?

  1. There are no public instance variables.

  2. All persistent values are accessed using getxxxand setxxxmethods.

  3. It may have many constructors as necessary.

  4. All of the above are true of a Java bean.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A Java Bean must have a no-argument constructor (default or explicit). If it has many constructors, it must include one with no arguments to be a valid Bean. However, Option D ('All of the above are true') claims C is true. Since C (having many constructors) violates the no-arg constructor rule without qualification, D is false. If C is the 'correct' answer for 'what is NOT true', it is factually consistent because C describes a state that violates Bean conventions. The source claims C is the correct answer.

AI explanation

The JavaBeans convention centers on a single no-argument constructor so that builder tools and frameworks can instantiate the bean reflectively without needing to know how to supply arguments. Treating a bean as free to declare "as many constructors as necessary" runs counter to that convention, which is why this is the statement that is not true of a bean. The other statements — no public instance variables, and access via getXxx/setXxx — are hallmarks of proper bean encapsulation.