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

Can we override constructors?

1008


What is the purpose of format function?

1186


Write a code to create a trigger to call a stored procedure

990


Objects or references which of them gets garbage collected?

971


Can singleton class be cloned?

1059


Tell me are there implementations for sorting and searching in the java libarary?

1044


Can a class be private in java?

1003


What is difference between ++ I and I ++ in java?

990


What is the this keyword?

1037


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

2343


Why heap memory is called heap?

1052


What are java threads?

1141


What are design patterns and please explain?

1094


What is a line separator in java?

990


What is the use of inner class?

1048