38.constructor_inheritance

 // constructor inheritance


class parent

{

parent()

{

System.out.println("parent constructor called");

}

}

class child extends parent

{

child()

{

System.out.println("child constructor called");

}

}

class // constructor inheritance


class parent

{

parent()

{

System.out.println("parent constructor called");

}

}

class child extends parent

{

child()

{

System.out.println("child constructor called");

}

}

class constructor_inheritance

{

public static void main(String[] args) {

child obj = new child(); 

}

}

{

public static void main(String[] args) {

child obj = new child(); 

}

}

OUTPUT:

parent constructor called

child constructor called

Comments