Can we override a constructor of super class in sub class of the same class. If yes, how? If no, why?
class Super{}
class Sub extends Super
{
//write code, if yes
}
No, you cannot override the constructor of the Super class. JVM will definitely call the super class constructor while creating the child class instance. So, whenever you create a subclass instance, it will invoke the baseclass constructor and then continue with the subclass constructor statements. Constructors are not Methods that can be overriden
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With