+ 2
What's the use of super Keyword in JAVA
JAVA
3 Respuestas
+ 4
Super can refer to a value or method of a class' superclass. For example:
class Demo {
void talk() {
System.out.println("Hi!");
}
}
class Dekozolavo extends Demo {
super.talk();
}
Output:
Hi!
Another use for super() is to call the superclass' constructor, for example, in a subclass' constructor:
class Demo {
Demo() {
System.out.println("Bye!");
}
}
class Dekozolavo extends Demo {
Dekozolavo() {
super();
}
}
Output:
Bye!
Happy coding! 😁 (will add more later, I'm in a rush) EDIT: I've added some additional information.
+ 3
It points to the parent object. The class from which your class inherits.
+ 2
thanxx guyzz for the help....I appreciate that