Ruby - Classes and Objects
What will be the output of this Ruby code?
class Dog
def bark
"Woof!"
end
end
fido = Dog.new
puts fido.barkclass Dog
def bark
"Woof!"
end
end
fido = Dog.new
puts fido.barkDog has a method bark that returns the string "Woof!".fido from Dog using new. Calling fido.bark returns "Woof!" which is printed.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions