Sunday, 18 December 2022

develop a program which implements concepts of overriding(any example )

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

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...