Java抽象类和方法
用了Java很多年,很少涉及到抽象类的使用。现在快毕业了,找工作的时候,首当其冲的面试题就是“Java 抽象类和接口的区别”。好吧,为了以后自己方便,也为了看到这篇文章的读者方便,引用一下官网的解释。
An abstract class is a class that is declared abstract—it may or may not include abstract methods.
抽象类可以含有非抽象方法,也可以不含抽象方法。
Abstract classes cannot be instantiated, but they can be subclassed.
抽象类可以被继承,但不能new。
An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:
抽象方法没有方法体,以分号结尾,如下:
<div class="codeblock">abstract void moveTo(double deltaX, double deltaY);
页:
[1]