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 sound
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 sound
Solution
The output of the code will be:
Bark Meow
Similar Questions
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 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 A
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 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 the following code?class Myclass: x=0 def incre(self): self.x+=1 def disp(self): print(self.x)ob1=Myclass()ob1.incre()ob1.disp()ob2=Myclass()ob2.incre()ob2.disp()
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.