Does class inherit constructors of its super class
Answer : No, class do not inherit constructor of its super class but a constructor from subclass can call constructor of super class. Please have example below:
package com.javahonk.overridenExample; public class SoftwareEngineer extends Employee { public SoftwareEngineer(int value) { super(value); } public static void main(String[] args) { new SoftwareEngineer(100); } } class Employee { public Employee(int value) { System.out.println("Value pass from " + "child class: " + value); } }
Output:
Value pass from child class: 100