Learn Pain Less

HomeOur TeamContact
Java
What is the use of super keyword in JAVA
Pawneshwer Gupta
Pawneshwer Gupta
March 22, 2015
1 min
What is the use of super keyword in JAVA

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){
System.out.println(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.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

startsuper keywordjava tutorial

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

Working with Files, Folders java
Working with Files, Folders java
March 25, 2015
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media