serialization - Do Interfaces provide specific meaning to objects in Java -


i have doubt interfaces in java:

when class implements interface, happen if not implement methods? merely implementing interface , provide change of meaning class ?

for example have 2 classes, test1 , test2

public class test1 implements serializable {  }   public class test2 {           } 

except fact test1 implements serializable, classes test1 , test2 identical. in case there difference between functionalities/properties of objects of test1 , test2? possible break down objects of test1 class bytes (just because class test1implements serializable)?

if yes, means implementing interface provides additional meaning objects of class?

straight documentaion of serializable -

serializability of class enabled class implementing java.io.serializable interface. classes not implement interface not have of state serialized or deserialized. serialization interface has no methods or fields , serves identify semantics of being serializable.

link

q1> in case there difference between functionalities/properties of objects of test1 , test2?

serializable marker interface, means there no method or field.

q2> would possible break down objects of test1 class bytes (just because class test1 implements serializable?
yes.

q3> if yes, means implementing interface provides additional meaning objects of class?

object serialization produces stream information java classes objects being saved. serializable objects, sufficient information kept restore objects if different (but compatible) version of implementation of class present.

thhe class can optionally define following methods:

  • a writeobject method control information saved or append additional information stream

  • a readobject method either read information written corresponding writeobject method or update state of object after has been restored

  • a writereplace method allow class nominate replacement object written stream

link


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -