Sobes.tech
Junior — Middle

Can the use of abstract classes be considered outdated in modern programming?

sobes.tech AI

Answer from AI

Using abstract classes is not an outdated practice. Abstract classes are useful when you need to define common base functionality and partially implement behavior that inheritors should extend or override.

In modern programming, interfaces with default methods (starting from Java 8) are often used, which extend capabilities without inheritance. Nevertheless, abstract classes remain relevant, especially when you need to store state or implement part of the logic.

Example:

abstract class Animal {
    abstract void sound();
    void sleep() {
        System.out.println("Sleeping...");
    }
}

class Dog extends Animal {
    void sound() {
        System.out.println("Bark");
    }
}
Can the use of abstract classes be considered… - sobes.tech