Gyh's Braindump

Java Abstract Class

tags
Abstract Class
source
DT-On Java 8

Purpose

Establish a basic form for all the derived classes. To express only the interface, and not a particular implementation.

  • no actual instances

Abstract Class

positioneaseboxintervaldue
front2.5002021-01-23T15:52:20Z

Classes have abstract methods (or not).

abstract class Basic {
    abstract void f();
}

Derived classes of abstract classes must implemente abstract methods. If not, the derived class is still abstract class.

abstract class Base2 extends Basic {
    int f() { return 111; }
    abstract void g();
    // f still not implemented
}

Allow almost all Java Access Control modifiers, except private abstract (no sense for it); whereas Java Interface only allow public methods.