This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
The clone method in Object class was set protected so that other classes are not able to access it on an instance of a class. You first need to clear your mind about protected access.
Here both B and C classes can access the val variable, but only on an instance of their own classes. So if you try this
Coming back to clone method, suppose you create a class like this
Now only the Employee class can clone its instances. If clone was declared public in Object class, then other classes would've been able to clone instances of Employee class. But there won't be any deep cloning i.e. if you clone an instance of Employee class, then the original object and the clone Employee objects would use the same Address object. That's why it is made protected. If you want other classes to be able to clone instances of your class, you'll override the clone method, make it public and take care of deep cloning...