How do we implement cloning for a class?
Simply override the clone() method as defined in Object. You probably want to implement the Cloneable interface, as well.
In what scenario, can we do that?
You can do that in any scenario in which you want to be able to duplicate an instance of a given class. In addition, if you are making extensive use of Cloneable objects but, specifically, want one (or a few) classes to be non-Cloneable, you might consider implementing the clone method and throwing a CloneNotSupportedException. I suspect you'd have to have a very good reason for doing so, though, as it could be confusing.
Is there any relation between implementations of cloning and equals()?
In general, x.clone().equals(x).
However, that isn't always true. Check out the
API Spec for Object for more details.