A class that has one or more abstract methods.
** Abstract method ** is a method that declares only the definition of arguments and method names without describing specific processing.
Abstract class declaration.java
abstract class class name{}
Abstract method declaration.java
abstract Return type Method name(Argument type Argument name);
⭕️ Superclass methods can be ** overridden ** (rewritten) in subclasses.
❌ Cannot inherit multiple classes.
❌ Cannot be instantiated directly.
A variable and method type defined without describing the specific processing of the method included in the class.
Interface declaration.java
interface Interface name{}
Interface implementation.java
class class name implements interface name{}
⭕️ Only the method type can be described first, and the process can be described immediately before use.
⭕️ Multiple inheritance of the interface is OK.
Son Goku (super class) can take over the surname of Son to multiple names of Son Gohan (subclass) and Son Goten (subclass).
Also, if Gohan becomes a son, the surname will be rewritten to Suzuki (override).
Gohan can take over the specifications of Goku to Saiyan and Chichi to Earthling.
A clear gene can be determined immediately before.
Recommended Posts