What is the output of the following code? python class Animal: def sound(self): print("Some sound") class Dog(Animal): def sound(self): print("Bark") class Cat(Animal): def sound(self): print("Meow") def make_sound(animal): animal.sound() dog = Dog() cat = Cat() make_sound(dog) make_sound(cat)Some sound\nSome soundBark\nMeowMeow\nBarkBark\nSome soundClear ResponseSave & Next
Question
What is the output of the following code? python class Animal: def sound(self): print("Some sound") class Dog(Animal): def sound(self): print("Bark") class Cat(Animal): def sound(self): print("Meow") def make_sound(animal): animal.sound() dog = Dog() cat = Cat() make_sound(dog) make_sound(cat)Some sound\nSome soundBark\nMeowMeow\nBarkBark\nSome soundClear ResponseSave & Next
Solution
The output of the code will be:
Bark Meow
Similar Questions
What is the output of the following code? python class A: def display(self): print("Class A") class B(A): def display(self): print("Class B") class C(A): def display(self): print("Class C") obj = B() obj.display() obj = C() obj.display() Class A\nClass AClass B\nClass CClass A\nClass CClass B\nClass AClear ResponseSave & Next
What is output of the following code ?class Animal {void makeSound(){System.out.prntln("Animal sound");}}class Dog extends Animal {void makeSound(){System.out.println("Bark");}}public class Test{public static void main(String[] args) {Animal a = new Dog();a.makeSound();}}Question 19Answera.Runtime errorb.Barkc.Compilation errord.Animal soundClear my choice
what is the output of following python code? class myclass: def __init__(self,a): self.a = a print(self.a)o=myclass()
What is the output of the below code?Code:class Cat: def __init__(self, age): self.age = age def set_age(self, num): self.age = num def get_age(self): return self.age cat1 = Cat(2)cat2 = Cat(4)cat1.set_age(cat2.get_age())cat2.set_age(5)cat3 = Cat(cat1.get_age() + cat2.get_age())print(cat3.get_age())*10965
What will be the output of below Python code?class A(): def __init__(self,count=100): self.count=countobj1=A()obj2=A(102)print(obj1.count)print(obj2.count)100100100102102102ErrorClear ResponseSave & Next
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.