Abstract Classes in Java


Abstract classes cannot be instantiated and are used to provide a base for subclasses to build upon.

Source Code

abstract class Animal {
    abstract void makeSound();
    void eat() {
        System.out.println("Animal is eating");
    }
}
class Dog extends Animal {
    void makeSound() {
        System.out.println("Bark");
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments