What is the use of super keyword in java I have seen it getting used in pojos and constructers, never really understood why it is used and where I can use them
java - When do I use super()? - Stack Overflow
Can someone please explain the 'super' keyword in Java like I'm eight years old?
Difference between this() and super() keyword?
https://www.geeksforgeeks.org/difference-super-java/
More on reddit.comI made it super easy to find keyword ideas automatically.
Interested in selling this side project?
More on reddit.comIs it Possible to Override a Method in the Parent Class and Still Call it Using the Super Keyword?
Can Super be Used in Static Methods?
What is The Knowledge Pass, and How Does it Work?
Videos
Calling exactly super() is always redundant. It's explicitly doing what would be implicitly done otherwise. That's because if you omit a call to the super constructor, the no-argument super constructor will be invoked automatically anyway. Not to say that it's bad style; some people like being explicit.
However, where it becomes useful is when the super constructor takes arguments that you want to pass in from the subclass.
public class Animal {
private final String noise;
protected Animal(String noise) {
this.noise = noise;
}
public void makeNoise() {
System.out.println(noise);
}
}
public class Pig extends Animal {
public Pig() {
super("Oink");
}
}
super is used to call the constructor, methods and properties of parent class.
I'm currently taking a Java course at my school and I couldn't really find any simple answers online. If anyone could help I would really appreciate it.