super keyword can be used to invoke parent class constructor

Java Programming Language / Class, Object and Methods in java

908

Program:

 class Parent{
	Parent(){
		System.out.println("I am Parent class");
		}
}

class Child extends Parent{
	Child(){
	super();
	System.out.println("I am Child class");
	}
}

class SuperKeyword {
	public static void main(String args[]){
	Child obj=new Child();
	}
}

//The super keyword can also be used to invoke the parent class constructor.

  

Output:

I am Parent class
I am Child class
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.