Java OCA OCP Practice Question 152

Question

Suppose you want to create a class that compiles and can be serialized and deserialized without causing an exception to be thrown. Which statements are true regarding the class?

Choose all correct options.

  • A. If the class implements java.io.Serializable and does not implement java.io.Externalizable, it must have a no-args constructor.
  • B. If the class implements java.io.Externalizable, it must have a no-args constructor.
  • C. If the class implements java.io.Serializable and does not implement java.io.Externalizable, its nearest superclass that doesn't implement Serializable must have a no-args constructor.
  • D. If the class implements java.io.Externalizable, its nearest superclass that doesn't implement Externalizable must have a no-args constructor.


B, C.

Note

If a class implements Externalizable, it must have a no-args constructor.

If a class implements Serializable and does not implement java.io.Externalizable, its nearest non-externalizable superclass must have a no-args constructor.




PreviousNext

Related