Inheritance and polymorphism 2

  This time I'll continue discussing the inheritance and polymorphic. 
1. Abstract class is quite simliar with interface. Actually, interface is a pure abstract class.T hen it like a superclass(actually not) with all abstract methods,so all methods must be implemented and make a class have a different attribute.The different is they have no relationship like super and sub.When we use an interface as a polymorphic type,the objcet can be from anywhere inheritance tree.Only requirement is that the objects are from a class that implements the interface. Allowing classes in different inheritance trees to implement a common interface.I think I've understanded your point.
2.I think there're some action represent polymorphism.One is when we use it as arguments reference to invoke the method of subclass's object.Another is we use it making an array objcet to hold that type(maybe subclass type). (Oh,there is a point that a reference variable of type Object can't be assigned to any other reference type without a cast.Maybe this is have no relation with poly,just want to tell you what i've understand).Back to polymorphism,the last is interface,it can represent different roles of a class,like Dog is a Pet,also is a Animal.
  Above these,some is my thought and some is from my book but I know it.If there is something wrong or something i'm not say, hoping you can point out.Thank you so much!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值