Abstract Class
An abstract class is a class that cannot be instantiated directly and is meant to be extended. It can contain abstract methods (declared without a body) that subclasses must implement, as well as normal methods, fields and constructors that subclasses share.
Use an abstract class when related classes share common code and state; use an interface when unrelated classes only need to share a set of methods. In Java a class can extend only one abstract class, but it can implement several interfaces.
abstract class Animal {
abstract String sound();
void speak() { System.out.println(sound()); }
}
class Dog extends Animal {
String sound() { return "Woof"; }
}
new Dog().speak(); // Woof