public abstract class Demo14 { public String var = "123"; public abstract double t1(); public void t2(String q) { System.out.println("123"); q = "1233211231312312"; } }
abstract 类可以声明数据变量,而interface不行除非是static final的变量。interface是一种特殊的abstract类只能implement不能继承,而abstract只能继承
abstract类中的抽象方法必须加上abstract不加则要加入方法体,可供继承的类重写和继承
public class Demo15 extends Demo14{ @Override public double t1() { return 0; } }
只能通过继承的方式来重写abstract类
标签:Java,继承,abstract,Demo14,interface,public From: https://www.cnblogs.com/shishenapr/p/17168151.html