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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Default Constructor" Watch "Default Constructor" New topic
Author

Default Constructor

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
Can a default constructor of any class has package access or not? can any one give me brief idea about it..


Abhishek
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Default constructors have two access levels, public and default. Public classes get public access level for their default constructors.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Charith Fernando
Ranch Hand

Joined: Sep 12, 2005
Posts: 67
hi

Default Constructor which is implicitly inserted by the compiler if there's no constructor, then it takes the access level of the class.

if the access level of the class is public then the access level of the default constructor will be also public, if the access level of the class is default then the access level of the constructor will be also default... and will continue in that fashion for all other access levels...

NOTE: constructors can be of any access level, even the default constructor which the compiler puts in can be of any access level because if the class is not a top level class then it could have any access level. Only top level classes can have only either public or default


Charith I Fernando<br />SCJP5, SCWCD, SCBCD, BSc(Hons) IS<br />+94 773 263 222 (mobile)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Only top level classes can have only either public or default


One "only" too many. Should be "Top level classes can have only either public or default".


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Charith Fernando
Ranch Hand

Joined: Sep 12, 2005
Posts: 67
agreed with the correction
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default Constructor
 
Similar Threads
Default constructor..
"JavaRanch Rule Round-up Game" error?
Inheritance Issue
Again java cap 38
Default Constructor in Sub/Super Class