Why can’t constructors be final, static or abstract in Java?

When you set a method as final, it means : “You don’t want any class override it”, but constructor by JLS definition can’t overridden,so it is clean.

When you set a method as ‘abstract’,it means:”Method don’t have any body and you want to implement it at another time in a child class”, but the constructor is called implicitly when the new keyword is used so it can’t lack a body.

When you set a method as ‘static’, it means: “Method belong to class, not a particular object” but constructor implicitly called to initialize an object, so there is no purpose in having a static constructor.

public class FinalConstructor { 

//Illegal modifier for the constructor in type FinalConstructor; 
//only public, protected & private are permitted 
private final FinalConstructor () { } 

}

2 Thoughts on “Why can’t constructors be final, static or abstract in Java?

  1. Prateek Gupta on March 3, 2015 at 2:18 pm said:

    As static function can be accessed without creating object and thus whole crisp of using Constructor is destroyed.

  2. Can abstract keyword be used with constructor? Explain.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation