File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes access modifier for constructor ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "access modifier for constructor ?" Watch "access modifier for constructor ?" New topic
Author

access modifier for constructor ?

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
what is the "access modifier" for the no-argument constructor provided by the compiler when no constructor is explicitly provided in the code

public, is always "friendly",always defaults to the access modifier provided for the class or it depends on the compilation options of javac
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Hey that's a really good question Mark! I would guess it's public, but I don't know for sure!

Rob


Rob
SCJP 1.4
Tarik Makota
Greenhorn

Joined: Jan 29, 2002
Posts: 23
i would say it is public.
public Object() is constructor for Object class
Ruchi Kolla
Greenhorn

Joined: Jan 24, 2002
Posts: 19
Originally posted by Rob Ross:
Hey that's a really good question Mark! I would guess it's public, but I don't know for sure!

Rob

For sure its public. You can create instance of the class from any package.
Sai Patnala
Ranch Hand

Joined: Jan 09, 2002
Posts: 60
Access modifier for the default constructor is same as the access modifier given to the class.
So if a class has public access, access modifier for default constructor is also public.
In no case a top level class can be protected nor private, so there is no way default constructor be protected nor private.
But we must understand that user defined default constructor can be private, in case you want to implement Singleton pattern.
[ January 30, 2002: Message edited by: sai k patnala ]

SCJP2, SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access modifier for constructor ?