Ruby program to call a superclass constructor from sub-class using the super() method
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 superclass constructor from the sub-class using the super() method is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created two classes SuperClass, SubClass. We inherited SuperClass into SubClass. And, we used the super() method to call the superclass constructor from the subclass and printed appropriate messages.
need an explanation for this answer? contact us directly to get an explanation for this answer