Master Java Super Keyword with W3Schools: A Complete Guide

Robert Jul 13, 2026

Of the many keywords in Java, the 'super' keyword holds a unique position and plays an integral role in implementing inheritance and polymorphism. It allows you to invoke special methods from the super class in the subclass, enabling code reuse and maintainability. In programming, efficient and understandable code is a priority, and 'super' helps achieve just that.

10 Example of this keyword in Java
10 Example of this keyword in Java

Understanding the 'super' keyword in Java is crucial for any developer. It can refer to a special variable or method of the superclass, and it can also be used to invoke the constructor of the immediate superclass. Let's unpack these functionalities further.

Java List of Keywords (All Reserved Words) | Complete Java Reference Guide
Java List of Keywords (All Reserved Words) | Complete Java Reference Guide

Using 'super' to Refer to Superclass Variables and Methods

The 'super' keyword can be used to access member variables or methods of the superclass that are overridden by the subclass. It helps maintain code clarity and reduces the risk of accidental overriding.

java keywords  you must know
java keywords you must know

Referencing Superclass Variables

The 'super' keyword can be used to access instance variables and static variables of the superclass. It helps to distinguish between similar named variables in the super and subclasses.

Famous Keywords in Java
Famous Keywords in Java

```java class Animal { String name = "Animal"; Animal() { System.out.println("Animal"); } } class Dog extends Animal { String name = "Dog"; Dog() { super(); System.out.println("Dog"); } } public class Test { public static void main(String args[]) { Dog d = new Dog(); System.out.println(d.name); } } ```

In the above code, the 'super' keyword is used to invoke the constructor of the superclass Animal, which is "Animal". The output is to print "Animal Dog". The 'super' keyword helps in calling the constructor of the immediate superclass.

Invoking Superclass Methods

You can use 'super' to invoke methods in the superclass that are hidden by methods in the subclass. This ensures that the correct method is called.

๐Ÿ”ฅ Java Super Keyword Explained! ๐Ÿš€
๐Ÿ”ฅ Java Super Keyword Explained! ๐Ÿš€

```java class Shape { void draw() { System.out.println("Drawing a shape"); } } class Rectangle extends Shape { void draw() { System.out.println("Drawing a rectangle"); } void print() { super.draw(); } } public class Test { public static void main(String args[]) { new Rectangle().print(); } } ```

Here, the 'super' keyword is used to call the 'draw' method from the Shape superclass within the Rectangle subclass.

Using 'super' to Invoke Superclass Constructors

The 'super' keyword can also be used to call a constructor from a superclass.

the key words in this language are used to describe something
the key words in this language are used to describe something

Calling Constructors Using 'super' Keyword

The 'super' keyword should be the first statement in a subclass constructor. It can be used without any argument, which implies calling the superclass's no-argument constructor. However, it can also be used with arguments, which implies the superclass's respective constructor.

Java Programming
Java Programming
Static Keyword In Java With Examples And Best Practices - JavaTechOnline
Static Keyword In Java With Examples And Best Practices - JavaTechOnline
Keywords in Java - Java Reserved Words - TechVidvan
Keywords in Java - Java Reserved Words - TechVidvan
Static keyword in Java (Static class, variable, method and block)
Static keyword in Java (Static class, variable, method and block)
The new keyword in Java programming language - Codeforcoding
The new keyword in Java programming language - Codeforcoding
Java Keywords
Java Keywords
What Keyword is Used to Create a Package in Java?
What Keyword is Used to Create a Package in Java?
Super Keyword in Java | Learn Coding
Super Keyword in Java | Learn Coding
Java Exception Keywords
Java Exception Keywords
the different types of html tags are shown in this screenshote screen graber
the different types of html tags are shown in this screenshote screen graber
Top Features of Java Every Beginner Should Know โ˜•๐Ÿš€
Top Features of Java Every Beginner Should Know โ˜•๐Ÿš€
๐Ÿ“˜ Must-Know Java Keywords Explained Simply ๐Ÿ”‘
๐Ÿ“˜ Must-Know Java Keywords Explained Simply ๐Ÿ”‘
Beginner's Guide to Learning Java
Beginner's Guide to Learning Java
โ˜• Java Basics Cheat Sheet for Beginners | Learn Java in One Page ๐Ÿš€
โ˜• Java Basics Cheat Sheet for Beginners | Learn Java in One Page ๐Ÿš€
10 Best Websites to Learn Java for Free in 2026
10 Best Websites to Learn Java for Free in 2026
9 great java project ideas for beginners to use in the web design process
9 great java project ideas for beginners to use in the web design process
different types of languages and their uses
different types of languages and their uses
Java Data Types Explained
Java Data Types Explained
Java Syllabus (2026). #webdevelopmentโœจ #coding #fblifestyle #programming | Premi Coding | Facebook
Java Syllabus (2026). #webdevelopmentโœจ #coding #fblifestyle #programming | Premi Coding | Facebook
core java classes in Pune
core java classes in Pune

```java class MyClass { MyClass() { System.out.println("Iโ€™m the parent constructor"); } MyClass(String s) { System.out.println("Iโ€™m the parent constructor which takes a string"); } } class MySubClass extends MyClass { MySubClass() { super(); System.out.println("Iโ€™m the child constructor"); } MySubClass(String s) { super(s); System.out.println("Iโ€™m the child constructor which takes a string"); } } ```

In this code, the 'super' keyword gets used both with and without arguments, correctly calling the constructors from the superclass.

Having explored the uses of 'super' extensively, its value in code clarity and improved architecture becomes evident. It forms a critical aspect of Object-Oriented Programming (OOP) in Java. Understanding where to use 'super' will help you write code that is simpler, more efficient, and easier to maintain.