Tuesday, 26 November 2013

Why clone method not visible in all of our class even we know that Object class is parent of all classes

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

Very Impotent Links for Java and Portal development development

Jar Download for Spring  Maven Or Gradel Dependency for Spring