aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's q1 on constructor from single topic 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 "Dan Watch "Dan New topic
Author

Dan's q1 on constructor from single topic

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Which of the following modifiers can be applied to a constructor?
a. abstract
b. final
c. private
d. protected
e. public
f. static
g. synchronized
h. transient
i. volatile
j. native
k. strictfp
l. None of the above.
The answer exclude synchronized. However following code compiles and works. As question is saying which modifiers CAN be applied, it should be part of answer list.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Barkat Mardhani:

Not so fast there, partner! That isn't even a constructor you've declared there! Once you provide a return type, you no longer have a constructor for class B, you have a method within class B named B.
If you were to remove the return type, you'd have a constructor and the compiler will give you an error.
Just to back that up, let's refer to the JLS, §8.8.3 Constructor Modifiers:

Unlike methods, a constructor cannot be abstract, static, final, native, strictfp, or synchronized.


SCJP Tipline, etc.
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Thanks Corey. That was quick reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's q1 on constructor from single topic