Question
What will be the output of the following code
snippet? class Animal: def sound(self): return "Some sound" class Dog(Animal): def sound(self): return "Bark" dog = Dog() print(dog.sound())Solution
This code demonstrates inheritance in object-oriented programming. The Dog class inherits from the Animal class. The Animal class has a method sound that returns "Some sound", while the Dog class overrides this method to return "Bark". When an instance of Dog is created and dog.sound() is called, the overridden method in Dog is executed, yielding "Bark". Why Other Options Are Wrong: A) Some sound: This option is incorrect because it represents the output of the sound method from the Animal class, which is overridden in the Dog class. C) Dog: This option is incorrect because it does not correspond to any return value from the sound method; it is not a valid method output. D) None: This option is incorrect as it implies that the sound method does not return anything, which is not true; it returns "Bark". E) Animal: This option is incorrect because it does not represent the output of any method in the code.
A shopkeeper purchases six small cold drink bottles for Rs. 100. For how much should he sell one such bottle to get a profit of 20%?
The cost price of two articles is same. One article is sold at 12.5% profit and another at 20% loss. If the selling price of one article is Rs. 390 more...
In a business there are two partners ‘P’ and ‘Q’. ‘P’ started the business with the capital of Rs. 20000 and after 3 months ‘Q’ joined h...
- A vendor got some mangoes at Rs. 200 per dozen and sold them at Rs. 22 per piece. He sold 7 dozen mangoes in all. Determine the total profit he made.
If 15 buttons are bought at Rs 1 and sold at the rate of 10 buttons at Rs 1, what will be the percentage profit?
- An item is sold after giving two back-to-back discounts of 25% and 10%. If its selling price comes out to be Rs. 6,075, find out the original marked price.
Axe and Wye purchases the Bikes at same price and later on Zed purchase both the bikes at the same price of Rs. 72000. But the profit % of Axe was A% wh...
- The average cost price of articles 'M' and 'N' together is Rs. 500 where the cost price of article 'N' is Rs. 100 more than that of article 'M'. If article...
A invested Rs. (P + 900). B entered after 2 months with Rs. 4P. If the ratio of B’s profit share to A’s is 10:7, find (P − 225).
A shopkeeper bought 200 articles at ₹40 each. He sold 120 articles at ₹50 each and the rest at ₹60 each. What is the profit percentage earned by t...