What is the use of super keyword in JAVA

Fetching Comments ...

Super keyword in java

Super keyword is used to call base class’s method or constructor. If we inherite a class and that class doesn’t have default constructor then we can call base class’s overloaded constructor inside our class’s constructor using supe keyword.

For example:

class Java{
	public Java(String title){

class Android extends Java{
	public Android(){
		super("Hello from Android class using super");

Super keyword will call matching constructor of base class, which means if you pass 2 parameters to super keyword then it will call base class’s constructor having 2 parameters. If you call super keyword without parameters then it will call default constructor of base class.

Share This:

LearnPainLess On Instagram

Get The Best Of All Hands Delivered To Your Inbox

Subscribe to our newsletter and stay updated.