OVERRIDEING
class Animal {
public void makeSound() {
System.out.println("Grr...");
}
}
class Cat extends Animal {
public void makeSound() {
System.out.println("Meow");
}
}
class Program {
public static void main(String[] args) {
Cat c = new Cat();
c.makeSound();
}
}
OUTPUT : Meow
No comments:
Post a Comment