/* * * final :加上后 这个方法会成为最终方法,无法被子类重写 * * abstract : 抽象类 此类不能被实例化 子类实例化时可以调用 * * */ public class FinalWithAbstract { public static void main(String[] args) { } } final class Person1{ public void eat(){ System.out.println("吃饭"); } } abstract class Person2{ public void walk(){ System.out.println("走路"); } }
#一切皆文件 import abc #利用abc模块实现抽象类 class All_file(metaclass=abc.ABCMeta): all_type='file' @abc.abstractmethod #定义抽象方法,无需实现功能 def read(self): '子类必须定义读功能' pass @abc.abstractmethod #定义抽象方法,无需实现功能 def write(self): '子类必须定义写功能' pass