Attaching the snippet of clone method implementation from object class, although object class does not implement cloneable interface, how is it allowed to use it ? Another one : Why couldn't clone method could stay in cloneable interface instead of object class ? What's the significance and importance aka real time application of marker interface which a usual interface could not have provided.
[clone method from object class] [1]: https://i.stack.imgur.com/QH4Yi.png
Search the web for what the cast operator does. It is a Cloneable.
Because interfaces can't declare implementations (since java 1.8 they can via the
defaultmechanism, butObject.clone()predates that by over 20 years or so).Do not look at the way Cloneable works as an example of good API design. It's not, but the developers of java didn't know any better back when the Cloneable stuff was designed.