• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

protected classes

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the access to protected methods outside their package be allowed to sub-subclasses too?
i mean, suppose i want to implement finalize() method of java.lang.Object and the class i am invoking it through is extending some other class, not Object directly. of course somewhere up the hierarchy its root is the Object. so does it have to declare explicitly the package as java.lang or not.
I have assumed that a class not extending another class can access the method without the package statement, coz such classes are implicitly assumed to directly extend Object.
Please comment.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anshuman,
Protected members(variables as well as methods) are accessible within the class in which they are defined and their subclasses.Yes any class which doesn't extend from any oyther class implicitly extends from Object class.Hence anyhow your class inherits the finalize() method of Object class.So their is nothing to worry about packages while dealing with Object class's resources!! ok?
Manoj Chandran
 
Anshuman Acharya
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yea, i understand. my problem was more towards the clone() method . but that has also been resolved... thanx
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic