Javatpoint
javatpoint.com โบ this-vs-super-in-java
Difference Between this and super in Java - Javatpoint
Difference Between this and super in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
Scaler
scaler.com โบ topics โบ java โบ this-and-super-keyword-in-java
This and Super Keyword in Java - Scaler Topics
March 8, 2022 - In the Child class, the print method calls the instance variables of the parent class using the super keyword. In comparison, the instance variables of child class don't need one. It doesn't matter whether the instance variable of parent class and child class share the same name; they can hold different values and are not overridden.
Videos
What is the difference between super & this keyword (Core ...
12:11
#51 This and Super Method in Java - YouTube
Java Constructors || Differences between super(),this() and ...
This and Super keywords with Constructor Examples In Java
09:04
Difference between THIS keyword and SUPER keyword in JAVA | this ...
TutorialsPoint
tutorialspoint.com โบ difference-between-super-and-this-in-java-program
Difference between super() and this() in java Program
With this similarity both these keywords have significant differences between them which are listed as below - ... class A { public int x, y; public A(int x, int y) { this.x = x; this.y = y; } } class B extends A { public int x, y; public B() { this(0, 0); } public B(int x, int y) { super(x + 1, y + 1);// calls parent class constructor this.x = x; this.y = y; } public void print() { System.out.println("Base class : {" + x + ", " + y + "}"); System.out.println("Super class : {" + super.x + ", " + super.y + "}"); } } class Point { public static void main(String[] args) { B obj = new B(); obj.print(); obj = new B(1, 2); obj.print(); } }
TutorialsPoint
tutorialspoint.com โบ Difference-between-super-and-this-in-Java
Difference between super() and this() in Java
class Animal { String name; Animal(String name) { this.name = name; } public void move() { System.out.println("Animals can move"); } public void show() { System.out.println(name); } } class Dog extends Animal { Dog() { //Using this to call current class constructor this("Test"); } Dog(String name) { //Using super to invoke parent constructor super(name); } public void move() { // invokes the super class method super.move(); System.out.println("Dogs can walk and run"); } } public class Tester { public static void main(String args[]) { // Animal reference but Dog object Animal b = new Dog("Tiger"); b.show(); // runs the method in Dog class b.move(); } }
Javatpoint
javatpoint.com โบ q โบ 6949 โบ difference-between-super-keyword-and-this-keyword
difference between super keyword and this keyword | 6949
Tutorials, Free Online Tutorials, Javatpoint provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.
Top answer 1 of 9
81
Lets consider this situation
class Animal {
void eat() {
System.out.println("animal : eat");
}
}
class Dog extends Animal {
void eat() {
System.out.println("dog : eat");
}
void anotherEat() {
super.eat();
}
}
public class Test {
public static void main(String[] args) {
Animal a = new Animal();
a.eat();
Dog d = new Dog();
d.eat();
d.anotherEat();
}
}
The output is going to be
animal : eat
dog : eat
animal : eat
The third line is printing "animal:eat" because we are calling super.eat(). If we called this.eat(), it would have printed as "dog:eat".
2 of 9
56
super is used to access methods of the base class while this is used to access methods of the current class.
Extending the notion, if you write super(), it refers to constructor of the base class, and if you write this(), it refers to the constructor of the very class where you are writing this code.
Scientech Easy
scientecheasy.com โบ home โบ blog โบ difference between super and this keyword in java
Difference between Super and This Keyword in Java - Scientech Easy
April 25, 2025 - One of the practical applications of the โthisโ keyword is constructor chaining. When a class has multiple constructors, each constructor can call another constructor using โthis()โ. This helps reduce redundant code and enhances code reusability. ... In addition to these, we can also use as a parameter in the method call and constructor call. The difference between super and this keyword in Java in tabular form is as follows:
Upgrad
upgrad.com โบ home โบ tutorials โบ software & tech โบ this and super keyword in java
This and Super Keyword in Java: Differences, Examples & Uses
September 24, 2024 - The primary purpose of the "this" keyword is to refer to the current object, while the "super" keyword allows access to the members of the parent class. These keywords help resolve naming conflicts, differentiate between instance variables and ...
GeeksforGeeks
geeksforgeeks.org โบ java โบ difference-super-java
Difference between super() and this() in java - GeeksforGeeks
November 9, 2022 - Note: super() should be first statement inside any constructor. It can be used only inside constructor and nowhere else. super() is used to refer only parent class's(super class's) constructor. this() is used to call the current class's constructor.
Tpoint Tech
tpointtech.com โบ this-vs-super-in-java
Difference Between this and super in Java - Tpoint Tech
In Java, the keywords "super" and "this" are essential for interacting with classes and objects. In addition to referring class members, they assist in manag...
Naukri
naukri.com โบ code360 โบ library โบ difference-between-this-and-super-in-java
Java Super vs This Keywords: Usage and Examples
Almost there... just a few more seconds