关于抽象类的整理(未完待续)

Important Points about Abstract class

  • abstract keyword is used to make a class abstract.---abstract关键字是一个类是否抽象的标志。
  • Abstract class can’t be instantiated.---抽象类不能实例化。
  • We can use abstract keyword to create an abstract method, an abstract method doesn't have body.---抽象方法只能有声明,不能有内容。
  • If a class have abstract methods, then the class also needs to be made abstract using abstract keyword, else it will not compile.---如果一个类中有抽象方法,那这个类必定是抽象的,即类必须有abstract关键字来修饰,不然无法通过编译。
  • Its not necessary to have abstract classes to have abstract method.---一个抽象类中不一定必须有抽象方法。
  • If abstract class doesn't have any method implementation, its better to use interface because java doesn't support multiple class inheritance.---如果一个抽象类中没有任何的方法的实现,那不是很有必要使用抽象类,我们可以使用interface去替代(因为interface中的所有方法都是abstract的,只是abstract省略而已),因为java不支持多重继承,但是java可以通过多重实现接口来变相实现多重继承。
  • The subclass of abstract class must implement all the abstract methods unless the subclass is also an abstract class.---子类必须实现抽象父类中所有抽象的方法,不然编译无法通过,除非子类依旧是一个抽象类。
  • All the methods in an interface are implicitly abstract.---interface中的所有方法都是abstract的
  • Abstract classes can implement interfaces without even providing the implementation of interface methods.---?
  • Abstract classes are used to provide common method implementation to all the subclasses or to provide default implementation.---抽象类为所有子类提供了公共的方法实现。
  • We can run abstract class like any other class if it has main() method.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值