0

I was reading through Serialization and Externalization in Java.

Individually I was able to use both the interfaces and was able to serialize and deserialize an object.

But as in Java, a class can implement multiple interface. I implemented both the interface in single class.

Now during runtime, how I can choose which serialization mechanism to choose?

I was wondering why this question has not been asked before! Is the question too lame?

Edit: My question is different from the question already asked on the forum.

Nicky
  • 1,025
  • 3
  • 15
  • 29
  • 1
    Interface `Externalizable's` Superinterface is `Serializable`. https://docs.oracle.com/javase/7/docs/api/java/io/Externalizable.html – Suresh Atta Aug 03 '16 at 17:14
  • My question is different from the links you guys have given. Have you ever tried implementing both interface in single class?? – Nicky Aug 03 '16 at 17:18
  • 3
    No, your question is identical. If you implement `Externalizable` you are automatically implementing `Serializable` since the former inherits from the latter. – Jim Garrison Aug 03 '16 at 17:21
  • You can't choose. `Externalizable` wins if present. – user207421 Aug 03 '16 at 17:51

0 Answers0