How does Serializable interface work

Serializable interface is a marker interface. A marker interface has no methods in it. They mark the class by identifying the java type that confirms to the interface.
My question is just by implementing a class as serializable how is a class getting serialized without any serializable method being executed.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It just marks the class as Serializable in the JVM. After this when ObjectOutputStream needs to serialize, it does check if the object is from the type.

Think of this like locked features - when you implement the interface, you just unlock them.
Mick BarryJava DeveloperCommented:
how it all works is documented here

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
One question to Venabili,

You told "Think of this like locked features - when you implement the interface,  you just unlock them."

But if you implement the same functionality which is present in ObjectOutputStream in one of your own class, and then use that class to serialize an Object (also you do not check in your implemented class whether the object to be serialized implements Serializable), will the object be not Serialized ??
We are talking about how the interface works, not when an object is considered serializable :)

As far as the interface is concerned, I still call it unlocking of features. I am not saying that it is the only way to unlock them but this is the way to unlock it for the default implementation.

What you want to do outside of the standard way is up to you. If you want to implement all the serializations from scratch, you are welcome to.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.