Ruby - Classes and Objects
What will be the output of this Ruby code?
class Cat
def meow
"Meow!"
end
end
kitty = Cat.new
puts kitty.meowclass Cat
def meow
"Meow!"
end
end
kitty = Cat.new
puts kitty.meowCat has a method meow returning "Meow!". Creating an instance kitty and calling meow returns that string.puts kitty.meow prints the string returned by meow, which is "Meow!".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions