Linked Questions

Popular Questions

Is there any difference in the behavior of the objects of variables a and b here?

class Animal {
    public void makeSound() {
        System.out.println("Grr...");
    }
}

class Dog extends Animal {
    public void makeSound() {
        System.out.println("Woof");
    }
}

class Program {
    public static void main(String args[ ]) {
        Animal a = new Dog();
        Dog b = new Dog();

        a.makeSound();
        b.makeSound();
    }
}

Related Questions