Java OCA OCP Practice Question 1454

Question

Which is not a requirement for a class to be immutable?

  • A. A private constructor is provided.
  • B. Any instance variables are private.
  • C. Methods cannot be overridden.
  • D. There are no setter methods.


A.

Note

Option A is a requirement of a singleton class rather than an immutable one.

The other three options are requirements of an immutable class.




PreviousNext

Related