Constructor Chaining in Java

When you have a class that extends another class in Java, initializing that child class will first call the parent’s initializer, and then the child’s. So if you have:

public class Base {
    public Base() {
        System.out.print("Base  ");
public class Derived extends Base {
    public Derived() {

The code Derived d1 = new Derived(); will print Base Derived.

Leave a Reply