Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Every class extends object but why it is not possible for
every object to invoke clone() method. ideally protected
methods should be accessible from sub classes. isn't it?

Answer Posted / aslam

Since the method is protected we can access clone method
only within the package or from subclasses outside the
package.

for ex:
class A{
public static void main(String arg[]){
new A().clone();
/* This is legal since class A is a subclass of Object and
we r accessing within the subclass*/

}
}

class B{
public static void main(String arg[]){
new A().clone();
/* Illegal since we r accessing it from outside object */
}
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between an if statement and a switch statement?

1158


How do you achieve polymorphism in java?

992


Can the garbage collection be forced by any means?

985


What is volatile keyword in java

1112


What are the new features in java 8? Explain

945


What are the procedures?

1057


What is outofmemoryerror in java?

1020


Which method must be implemented by all threads?

1259


What is the difference between a scrollbar and a scrollpane?

1045


What two classes are used to read data only?

1092


What is the default size of arraylist in java?

1115


Can a singleton class be inherited?

966


How objects of a class are created if no constructor is defined in the class?

1060


What is ternary operator?

998


What is :: operator in java?

966