Ruby program to call the overridden superclass method from the subclass
belongs to collection: Ruby Constructors/Destructors, Inheritance Programs
All Answers
total answers (1)
belongs to collection: Ruby Constructors/Destructors, Inheritance Programs
total answers (1)
Program/Source Code:
The source code to call the overridden superclass method from sub-class is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created two classes SuperClass, SubClass. And, we override the SayHello() method into SubClass by inheriting SuperClass into SubClass, and accessing the superclass method from subclass using the super() method. After that, we created an object of SubClass, and called SayHello() method of SubClass.
need an explanation for this answer? contact us directly to get an explanation for this answer