Examveda
Examveda

Which of the modifier can't be used for constructors?

A. public

B. private

C. static

D. protected

Answer: Option C


This Question Belongs to Java Program >> Constructors And Methods

Join The Discussion

Comments ( 2 )

  1. NITIN CHAUDHARY
    NITIN CHAUDHARY :
    7 years ago

    It’s actually pretty simple to understand – Everything that is marked static belongs to the class only, for example static method cannot be inherited in the sub class because they belong to the class in which they have been declared. Refer static keyword.
    Lets back to the point, since each constructor is being called by its subclass during creation of the object of its subclass, so if you mark constructor as static the subclass will not be able to access the constructor of its parent class because it is marked static and thus belong to the class only. This will violate the whole purpose of inheritance concept and that is reason why a constructor cannot be static.

  2. Nitin Thakur
    Nitin Thakur :
    7 years ago

    only public private protected and default modifiers are allowed for a constructor, Neither final or static is allowed.

Related Questions on Constructors and Methods

What is a constructor in Java?

A. A special method to create instances of classes

B. A method used for mathematical calculations

C. A method to perform string manipulations

D. An exception handling mechanism