Java OCA OCP Practice Question 169

Question

What interfaces can be implemented in order to create a class that can be serialized?

Choose all that apply.

  • A. No interfaces need to be implemented. All classes can be serialized.
  • B. implements java.io.Serializable. There are no methods in the interface.
  • C. implements java.io.Serializable, which defines two methods: readObject and writeObject.
  • D. implements java.io.Externalizable, which defines two methods: readObject and writeObject.
  • E. implements java.io.Externalizable, which defines two methods: readExternal and writeExternal


B, E.

Note

There are two ways to ensure that a class can be serialized.

You can implement Serializable, which is a tagging interface that defines no methods.

Or you can implement Externalizable, which defines the readExternal and writeExternal methods.




PreviousNext

Related