• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic