Ruby program to override the superclass method into sub-class
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 override the superclass method into 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. 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