Question
Consider the following code snippet (Java-like):
  class Animal {     public void makeSound() {       System.out.println("Animal makes a sound");     }   }   class Dog extends Animal {     @Override     public void makeSound() {       System.out.println("Dog barks");     }   }   public class Test {     public static void main(String[] args) {       Animal myAnimal = new Dog();       myAnimal.makeSound();     }   }   What will be the output of this code?Solution
This demonstrates runtime polymorphism (method overriding). Even though myAnimal is declared as type Animal, it actually refers to a Dog object. When makeSound() is called, the JVM (Java Virtual Machine) determines the actual type of the object at runtime and invokes the makeSound() method defined in the Dog class.
Who has acquired the title sponsorship rights for the domestic matches of the Indian cricket team?
Consider the following statements:
1.   The Kyoto Protocol operationalizes the Convention on Biological Diversity (CBD).
2.   The ...
Who is often referred to as the "Father of Geography"?
Which city in India will have a new Consul-General from Australia, as announced by Australian Prime Minister Anthony Albanese?
Who was recently sworn in as the 12th Governor of Jharkhand?
Which year did SEBI make BRSR mandatory for the top 1,000 listed entities by market capitalization?
The Indian Space Research Organisation (ISRO) recently announced the celebration of National Space Day. On which date will National Space Day be celebra...
Asia Cup 2023 will be hosted by _________________ .
Who inaugurated the first 'Global Symposium on Farmers' Rights' (GSFR) at the ICAR Convention Centre in New Delhi?
Among the following Universities, which University won the highest number of gold medals in the Khelo India University Games, held between May 25 to Jun...