Another "well thought" interview question!
In my opinion, the correct answer to that question is "don't call the
clone() method". This definitely avoids any cloning.
If the question was really meant to be "how to prevent cloning of a class I have no control over" (as I guess it was), then several things are wrong with the question. Most of all,
String is a particularly unsuitable example: firstly,
String doesn't support cloning at all (it doesn't implement
Cloneable), so the goal is already achieved. Secondly,
String is immutable, and therefore, even if it could be cloned, no one would ever do it - you don't need several independent copies of an immutable object. Thirdly, even if
String could be cloned, no harm could be done by the cloning, so there isn't any reason whatsoever to prevent someone from cloning a
String.
In any case, I'm not aware of any reasonable way to prevent a class that correctly implements
Cloneable interface from being cloned.