Ruby - Inheritance
What will be the output of this Ruby code?
class Animal; end class Dog < Animal; end class Cat; end puts Dog < Animal puts Cat < Animal
class Animal; end class Dog < Animal; end class Cat; end puts Dog < Animal puts Cat < Animal
ChildClass < ParentClass returns true if ChildClass is a subclass of ParentClass, otherwise false.Dog < Animal returns true because Dog inherits from Animal. Cat < Animal returns false because Cat does not inherit from Animal.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions