aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Constructor Modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Constructor Modifiers" Watch "Constructor Modifiers" New topic
Author

Constructor Modifiers

Jimmy Blakely
Ranch Hand

Joined: Jul 10, 2001
Posts: 57
Aside from accessibility modifiers, do constructors accept any other types of modifiers?

I'm currently testing the hypothesis that constructors can only be preceded by accessibility modifiers (public, private, protected, default). Is this true?
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Correct!
If you put a return type, java considers it to be a method and it will not create that constructor. Modifiers such a synchronized, native ext. wll throw a compile time exception.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Jimmy Blakely
Ranch Hand

Joined: Jul 10, 2001
Posts: 57
Never mind.
I just finished testing it out.
Constructors cannot accept static, final, abstract, synchronized, or native as modifiers.
Naturally, the same is true for transient and volatile since they are only used to modify variables and not methods.
 
wood burning stoves
 
subject: Constructor Modifiers