This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes protected access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "protected access" Watch "protected access" New topic
Author

protected access

Rishi Wright
Ranch Hand

Joined: Jun 25, 2003
Posts: 46
Hi 'all
say A & B are classes in different PACKAGES
and B extends A
Then
1)how can I call a PROTECTED OVERRIDEN method in A from B
2)How can I access the STATIC PROTECTED method of A from B
a simple example would be more helpfullllll.....
thank you
rishi
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Rishi,
Here is the example,

output is,
B
A
A.protected static:A
You get it?
Regards
Maulin
Rishi Wright
Ranch Hand

Joined: Jun 25, 2003
Posts: 46
Thnx Maulin...I wanted to confirm there is no other way to call superclass overridden method other than using super (I mean any reference variable)..
thnx agian
rishi
Selim Hendrickson
Greenhorn

Joined: Aug 14, 2003
Posts: 9
Maulin I'm confused. I thought the extending class would not be able to invoke protected methods through reference. Is super an exception to this rule?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: protected access
 
Similar Threads
Roundup Game Question #118
Question about Object class
Confused with protected access
Question in K&B Book - protected class
How the protected finalize method is called by garbage collector