Start learning 50% faster. Sign in now
In this code, the Dog class inherits from the Animal class, and it overrides the sound() method. This is a clear example of inheritance and method overriding in object-oriented programming. Let's break down the code and explain why A is correct and the other options are wrong: · Explanation of Correct Option (A): The Dog class extends the Animal class, which means it inherits the sound() method from Animal . However, Dog provides its own version of sound() , printing "Dog barks" instead of "Animal makes a sound". This is method overriding : a subclass providing a specific implementation of a method that was already defined in its superclass. Method overriding allows the subclass to provide its own version of the inherited method. · Why the Other Options Are Incorrect:
Who is awarded PETA India’s person of the year 2022?
Which country became the 101st member of the International Solar Alliance (ISA)?
Where is the Sixth Quad Leaders Summit held?
Who made history by becoming the first male player to participate in 150 T20 Internationals?
Where is the headquarters of UNESCO located?
What is "Operation Ajay" associated with?