Why clone method not visible in all of our class even we know that Object class is parent of all classes
→ When a protected member is inherited across package it becomes private member of inherited class
→ when a protected member is inherited within the same package it becomes default member of inherited class.
→ clone() from Object class is inherited into MyClass across package. Object class is in java.lang package and MyClass is in GoodQuestions package. So clone() method becomes a private member of MyClass class.
That explains why you are unable to access clone() method from TestSingleTon class.
No comments:
Post a Comment