Sobes.tech
Middle+

Why is the clone() method declared in the Object class and not in the Cloneable interface?

sobes.tech AI

Answer from AI

Cloneable is a marker interface. It does not contain any methods and only indicates to the JVM that an object can be cloned using the native Object.clone() method. Declaring clone() in Object makes it accessible to all classes, whether they implement Cloneable or not. If clone() were in Cloneable, a class that does not implement this interface would not be able to invoke it, which would break the basic cloning functionality supported by native code.

Why is the clone() method declared in the Object… - sobes.tech