+ 2

What's the use of super Keyword in JAVA

JAVA

15th Oct 2017, 9:53 PM
Yash Raghava
Yash Raghava - avatar
3 Answers
+ 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.
15th Oct 2017, 10:03 PM
LunarCoffee
LunarCoffee - avatar
+ 3
It points to the parent object. The class from which your class inherits.
15th Oct 2017, 10:05 PM
josh mizzi
josh mizzi - avatar
+ 2
thanxx guyzz for the help....I appreciate that
21st Oct 2017, 7:45 PM
Yash Raghava
Yash Raghava - avatar