File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructor??

 
srikanth reddy
Ranch Hand
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frnds
i have a simple doubt i.e can a constructor have an access modifier other than what class has ???
coz i read some where that the constructor has the same access modifier as that of class....

please help

srikanth
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it can . This of a singleton class whose c'tor is private. It's also a method in a class but a special method without return value.
[ September 23, 2005: Message edited by: Srinivasa Raghavan ]
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a simple doubt i.e can a constructor have an access modifier other than what class has ???
Absolutely. Class access modifiers may be public or default (package). Constructor access modifiers may be public, protected, default, or private.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this is about the default C'tor.
From JLS:
If a class declares no constructors then a default constructor, which takes no arguments, is automatically provided. If the class being declared is Object, then the default constructor has an empty body. Otherwise, the default constructor takes no arguments and simply invokes the superclass constructor with no arguments. If the class is declared public, then the default constructor is implicitly given the access modifier public. Otherwise, the default constructor has the default access implied by no access modifier (�2.7.4).
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
 
A Kumar
Ranch Hand
Posts: 980
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

yes you can...



Hope you got it..

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic