whhy we cannot use final keyword for a constructor
I think JVM calls cumstructor when we want tocreate an object of the class. We create objects for allocating memory for data members and variables. Once we make cumstructor as final we cant do modification as per final property. So we cant assume that every time create an object the memory will b same for each call. Thats y we cant make constructors as final.
as final makes any method unable to change it's parameters. so now imagine you call a class multiple times in your programs assigning different values for initialization. then multiple references are called of constructor but since it is final all references possess same identity so it throws a runtime error
So making a constructor final is not required, so it is not used with constructor. 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. We can't make constructor to be final because constructor is never inherited.
final can b used with class , method and variable. It is used with method to make it non- overridable . First of all constructor is not a normal method i mean like it doesn't return anything, and final work on normel methods, and it doesn't make sense to make a constructor final as how could u possibly override it.
Did Not Get The Answer?
Contact people of Talent-Core Java directly from here