and that clone() is protected, why it is not visible??
The protected and default access control levels are almost identical, but with one critical difference. A default member may be accessed only if the class accessing the member belongs to the same package, whereas a protected member can be accessed (through inheritance) by a subclass even if the subclass is in a different package.
Originally posted by Stevi Deter:
B and TestClass are not in the same package as Object, so they cannot see the protected java.lang.Object.clone() member that is inherited by A through extending Object.
Originally posted by Dinesh Tahiliani:
its giving me false, even though i implemented the Clone
Originally posted by Francesco Bianchi:
In your hierarchy, A comes right after Object. All the subsequent subclasses have to pass through A to reach Object members. And as long as both A, B and TestClass are in a different package from Object, A is THE ONLY class allowed to SEE protected Object members. But still A doesn't have a clone() method. It can just use it.
Originally posted by Ismael Upright:
If class X has a protected method doSomething() and we subclass this class with A, the method doSomething() is inherited and exists in class A. It can be used with instance a of class A as follows: "a.doSomething()". Right?