| 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: 6588
|
|
|
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 - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
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
|
 |
 |
|
|
subject: Default Constructor
|
|
|