今天的内容:
关键字:abstract。
定义格式: 访问修饰符 abstract class 类名
特点:
不能被实例化,即不能创建对象。
类的其他功能都存在。
必须被继承才能被使用。
抽象方法:
定义格式:访问修饰符 abstract 返回值 函数名();
注意:
抽象方法只能定义在抽象类中。
抽象方法只有方法名,没有定义。即没有方法体。
其子类必须重写该方法,或者也定义为抽象类。必须有子类最终实现抽象方法,否则子类和父类都不能实例化对象。
构造器、类方法(用static修饰的方法)不能被声明抽象方法。
明天的打算:继续学习Java
问题:无