Ruby program to call the overridden superclass method from the subclass
class SuperClass
def initialize
puts "SuperClass constructor";
end
def SayHello
puts "Say hello from SuperClass";
end
end
class SubClass < SuperClass
def initialize
puts "SubClass constructor";
end
def SayHello
super();
puts "Say hello from SubClass";
end
end
subObj = SubClass.new;
subObj.SayHello;
Output:
SubClass constructor
Say hello from SuperClass
Say hello from SubClass
