*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "constructor" Watch "constructor" New topic
Author

constructor

dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
public class A {
A(){}
}


A The class A can be referenced outside the package in which it is defined.

B The class A cannot be instantiated outside the package in which it is defined.

C The class A cannot be extended outside the package in which it is defined.

Why B & C are correct? It is a public class. Because of non-public constructor. Correct me if I am wrong.


SCJP-1.5<br />SCWCD-1.4
christian combarel
Ranch Hand

Joined: Aug 04, 2007
Posts: 47
Yes you're right.
If the constructor has a default acces level, you can neither instanciate the class nor extends it outside the package.



-------------
Chris
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: constructor
 
Similar Threads
class access
public
Output of the Program
constructor
what is right....and why???