+ 17

Why constructor cannot be final?

please explain clearly and easy to understand your answer..

14th Jul 2017, 1:24 PM
Sarath Kumar
Sarath Kumar - avatar
6 Respostas
+ 16
When you set a method as final it means: "You don't want any class override it." But the constructor (according to the Java Language Specification) can't be overridden, so it is clean. When you set a method as abstract it means: "The method doesn't have a body and it should be implemented 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: "The method belongs to the class, not a particular object." But the constructor is implicitly called to initialize an object, so there is no purpose in having a static constructor.
14th Jul 2017, 1:25 PM
Sarath Kumar
Sarath Kumar - avatar
+ 7
thnks to explan @whbe
16th Jul 2017, 3:58 AM
Sarath Kumar
Sarath Kumar - avatar
+ 1
the easy answer is that you can think or consider about constructor as "special method", it is a java language (rule) that made this method is constructor. also, because of the constructor can't be overriden. so, that's useless to make the costructor method is final. because the (final) keyword uses to prevent the override, and the constructor can't be overriden by defualt. hopefully it is clear
16th Jul 2017, 3:30 AM
whbe
whbe - avatar
+ 1
you're welcome my friend sarath
16th Jul 2017, 4:01 AM
whbe
whbe - avatar
0
...
15th Jul 2017, 4:02 AM
Panda Lim
Panda Lim - avatar
0
Constructors are not members of a class,so they cannot be inherited by the super class.Again since they cannot be inherited,they cannot be overridden,so it is of no use to declare a constructor as final.Generaly “final” keyword is used in Java for methods which we don’t want to be overridden. See method overridden here:- http://crbtech.in/Java-Training/method-overloading-overriding-java-2/
16th May 2018, 5:36 AM
pranit patil
pranit patil - avatar