Ruby program to override the superclass method into sub-class
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
puts "Say hello from SubClass";
end
end
subObj = SubClass.new;
subObj.SayHello;
Output:
SubClass constructor
Say hello from SubClass
