Consider following method
default void print(){
}
Which statement is true?
A. This method is invalid.
B. This method can be used only in an interface.
C. This method can return anything.
D. This method can be used only in an interface or an abstract class.
E. None of above.
题解
Java 8 的界面(interface)可以加入已经实作好程序的预设方法(default method)和静态方法(static)。预设方法使用「default」来修饰,只能给实体化出来的对象来调用使用;静态方法使用「static」来修饰,只能给界面来调用使用。
