aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes can a contructor be declared protected... 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 "can a contructor be declared protected..." Watch "can a contructor be declared protected..." New topic
Author

can a contructor be declared protected...

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
the code compiles....but what is the use of a protected contructor when they are never inherited?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

If I see correctly, the heading says "can a contructor be declared postive? " . A protected constructor allows the class to be inherited but cannot be instantiated outside of the package. So if a class com.mypackage.MyClass has protected constructor(s), then the MyClass can be inherited but cannot be instantiated outside of com.mypackage package...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
thanks Ankit

Raju
 
wood burning stoves
 
subject: can a contructor be declared protected...