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 kind of variables can a class consist?

997


Explain the Propertie sof class?

993


enlist some features of jdk.

908


Define max and min heap, also the search time of heap.

986


How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?

998


What is the difference in between cpp and java? Can u explain in detail?

1027


Can a static method be final?

1005


What are actual parameters?

965


How many boolean functions are there?

922


What is complexity and its types?

955


What is the difference between size and length in java?

927


Explain the scope of a variable.

1024


What's the difference between int and integer in java?

1094


What is a instance variable in java?

985


Is it possible to specify multiple jndi names when deploying an ejb?

938