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.
What is the Standard International Unit (SIU) of measurement of light (Illumination)?
Under Bharat series (BH), first 2 letters of BH plate represents ____________.
Which country has recently been declared polio free by WHO
Match the following Indian Space Research Organisation (ISRO) Space centres with their respective location.
Space Centres Location
(i) I...
Shore temple is situated in which state of India?
When is World Homeopathy Day observed annually?
The first ever masala bond was issued by:
.Pochampadu project, is a flood flow project in which of the following state?
Davis Cup is related to which sport?Â
MSDE collaborated with which company to launch the 'AI Careers for Women' initiative?