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.
What sum of money will become Rs.1352 in 2 years at 4 percent per annum compound interest?Â
Shivam invested 20000 at 12% p.a. simple interest for ‘x’ months. If at the end of ‘x’ months, he received a total amount of Rs.23200. What is t...
Rs. 10000 invested for 2 years in a scheme offering compound interest (compounded annually) of 15% p.a. gives an interest that is Rs. 25 less than the i...
Mitch placed Rs. 32,000 in a compound interest account with an annual rate of 30%, compounded semi-annually. After investing for a period of 15 months, ...
A person invests Rs. ‘a’ in SIP A and Rs. ‘b’ in SIP B. SIP A offers simple interest at 15% per annum, while SIP B offers compound interest at 2...
A woman invested Rs. 'x + 500' at 8% per annum simple interest and received Rs.360 as interest after 3 years. Calculate the interest she would earn if s...
A principal of Rs. 'x' is invested at an annual compound interest rate of 30%, compounded yearly, and grows to Rs. 2535 after 2 years. Calculate the sim...
Find the compound Interest on Rs. 8,000 @15 % p.a for 2 years 4 month Compounded annually?
Jeevan borrowed an amount of Rs. 'x' from a bank. Out of this, he lent 25% of the borrowed amount to Jeshu at a simple interest rate of 20% per annum fo...
A borrowed Rs. 9500 from B for his business. How much amount A will return to B at the end of 24 months such that the sum was borrowed at simple interes...