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 do you mean by constructor?

981


What is a string token?

1048


Why is java called java?

1049


What does s mean in regex?

1019


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

983


What is parameters example?

1030


What is concurrent hashmap and its features?

1095


What is a boolean used for?

1113


What is the function of character?

1053


What is the difference between dom and sax parser in java?

974


What does the “final” keyword mean in front of a variable? A method? A class?

997


What state is a thread in when it is executing?

962


what is a working thread? : Java thread

1038


Explain the use of shift operator in java. Can you give some examples?

977


What is double word?

974