aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a  Question about protected  access midifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a  Question about protected  access midifier " Watch "a  Question about protected  access midifier " New topic
Author

a Question about protected access midifier

abdelhameed obied
Greenhorn

Joined: Oct 03, 2007
Posts: 6
hi all
here is my code my question will follow

the compiler didnt give me a compilation error can any one tell me why please ?
i know that the protected is only available through inheritance so i was expecting a compilation error.
thanks
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4387
    
    8

But you are inheriting. NewClass extends NewClass2, so NewClass has access to NewClass2's protected members.
abdelhameed obied
Greenhorn

Joined: Oct 03, 2007
Posts: 6
as i understood it is allowed only though inheritance
but am accessing it from another instance of the class .
notice this : in the code


are they the same ?


Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Try to access like the code below, you'll understand!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a Question about protected access midifier