View Full Version : Is it possible to override constructors in Java?
rajuljain
06-25-2012, 12:39 AM
can we override constructors?
jamsen
09-26-2012, 09:59 AM
No, you can't override a constructor. They're not inherited. However, each subclass constructor has to chain either to another constructor within the subclass or to a constructor in the superclass.
thewebhostingdi
10-05-2012, 10:55 AM
Constructor is a method which have same name as class name and no return value.
Overriding means what we have declared in Super class, that exactly we have to declare in Sub class it is called Overriding. Super class name and Sub class names are different.
So as We can not declare same class(with same constructors) twice in same program, hence we can not Override Constructor.
AdrianG001
05-18-2022, 02:51 AM
No we cannot override the constructor. A constructor is a special member function of class with the same name as that of class. Its primary purpose is to initialize the data members of the instance of the class. Hence saying that it initializes the data members of the class would be wrong.
Powered by vBulletin® Version 4.2.4 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.