How the marker interface works has been asked and answered many times. Also how/why annotations instead of a marker interface has also been answered multiple times. Fortunately the forums have a search feature. You may like to try it. Also I strongly recommend that you go through some beginner's text on the subject.
Question - Have you read on the subject from any Core Java Fundamental's reference book? Like from 'Head First Java' or from 'Thinking in Java'?
I'd say it will be a good idea to read about Serialization first and then post specific questions if you do not understand a specific thing.
First, let's move this topic to Java in General, as Serialization is not really related to forum of "Threads and synchronization".
Avinash Tiwari wrote:
As we know Serialisable is a marker interface and doesn't have any enforced implementation.
Then how does the whole serialization mechanism work. How does JVM knows internally this.
Is there any inbuilt mechanism underlying this.
Serialization is a mechanism of the JVM -- and as such, it seems to allow stuff that violate specification. As for the Serializable interface, the mechanism simply checks it. If the class is Serializable, it can be serialized. Not sure what you mean by "doesn't have any enforced implementation".
Thanks for the reply.
As for basic principles of marker interface , yes I do understand they are kind of metadata to a class which JVM might be using.
However the question I have is , does implementing this interface provides kind of type checking only or do they serve other purpose too.
Like the implementer of the logic checks the type for object and determines whether it is of marker and then proceeds with respective business logic.
Is this the case which drove their existence.
However being at class level , the property was enforced on whole class and subclasses and to provide the marker capability to specific granular elements or methods , annotations were brought in.