aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Access control 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 "Access control" Watch "Access control" New topic
Author

Access control

sweety sinha
Ranch Hand

Joined: Jul 07, 2008
Posts: 76
source is: http://www.jdiscuss.com
You can only call public and protected constructors of the super class in a subclass if the subclass is not in the same package because only those are inherited.

my answer is true
but the answer given is false why?
chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

Well, i guess even the default constructors can be called.

Your answer is right if Constructors is replaced by "Methods"

Correct me if i am wrong.


Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
sweety sinha
Ranch Hand

Joined: Jul 07, 2008
Posts: 76
i think i have done a mistake, because constructor is never inherited
chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

Yes.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

Yes, constructor is never inherited.

The correct statement would be

You can only call public and protected constructors of the super class in a subclass if the subclass is not in the same package because only those are accessible.

Also remember that if you don't provide explicit constructor for a class, the default constructor provided by the compiler has the same accessibility as the class.....


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access control