Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider when Object.clone throws CloneNotSupportedException. Which statement is correct?

  • A.When the object is an array.
  • B.When the object's class does not implement Cloneable.
  • C.When any field of the object is not itself Cloneable.
  • D.When the class overrides clone without declaring the exception.

Answer: B

The check is on the object being cloned, not on its fields: without Cloneable the inherited method refuses. Arrays are the opposite case, being cloneable by definition, and a nested field that is not Cloneable is irrelevant because a shallow copy never tries to clone it.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.