Home
Tutorials Library
Artificial Intelligence
Computer Networks
Core JAVA
DBMS
Data Warehouse
Mobile Ad-Hoc Networks
Mobile Computing
Pattern Recognition
Software Engineering
Software Quality
Software Testing
Structured Query Language(SQL)
Tech Blog
Let's Test Out
C Programming Language
Computer Networks
Core Java
HTML & CSS
The Story
SUPER KEYWORD JAVA
Super Keyword In JAVA | Core Java Tutorial | Minigranth
Chapters
Introduction
Features of Java
Installing Java
Java Terminologies
First Java Program
Executing Java Program
Comments In Java
Java Data Types
Operators In Java
Type Conversion
Control Statements
Loops In Java
Branch Statements
Arrays In Java
Command Line Arguments
Recursion In Java
OOPs In Java
Classes, Methods & Objects
Method Overloading
Java Constructors
Static Keyword
This Keyword
Inheritance In Java
Super Keyword
Method Overriding
Dynamic Method Dispatch
Final Keyword
Abstraction In Java
Access Modifiers
Encapsulation In Java
Packages In Java
Exception Handling
Strings In Java
Java String Programs
Tutorials Library
Super Keyword In Java : Introduction
Super keyword in Java which is
used by subclass to refer to immediate parent class.
Super keyword is used in many ways out of which two most
common
ways are demonstrated below along with their syntax and respective examples.
Using
super
keyword to refer immediate parent class member(field and method).
A subclass can refer an immediate parent class member by using Member can be an instance variable or method of parent class.
Syntax
: To refer to immediate parent class member.
super
.member;
Using
super
in this context is useful when some members in both parent and child class are named same and you want to differentiate them.
Let’s see an example demonstrating this use of
super
.
Super Keyword Example : Case 1
Super Keyword Output : Case 1
Using
super
keyword to invoke immediate parent class constructor.
We can invoke immediate parent class constructor by using
super()
.
super()
is used to invoke default constructor and
super(parameters….)
is used to invoke parameterized constructor. Let's observe this with an example.
Super Keyword Example : Case 2
Super Keyword Output : Case 2
Note
: Invoking constructor using
super
should be the first statement in the block.
Previous
Next