A simple example of inheritance along explanation of constructor calling

class A {
    A() {
        System.out.println("Hey! I'm father of all.");
    }
}

class B extends A {
    B() {
        System.out.println("Hey! I'm child of A.");   
    }
}

class C extends B {
    C() {
        System.out.println("Hey! I'm child of B and younger one.");   
    }
}

public class Inheri {
    public static void main(String[] args) {
        C youngerone = new C();
    }
}

Comments

Popular posts from this blog

Zeller's Congruence

Property Event-Delegation

Method with variable arguments