Inheritance and polymorphism 1
来源:互联网 发布:网络圣战 编辑:程序博客网 时间:2024/04/29 05:05
The subclass inheritance all variables and methods from superclass. The subclass can have its own methods and variables, or it also can override the method of superclass. I think there is a relation with polymorphic. On the surface of polymorphism, we can have polymorphic arguments and return types, using the reference as arguments in method. I think one parameter is a reference variable of the superclass and the other is an object of the subclass, when we call the method, they link like declare an object and call the object's method. And because inheritance, if the subclass override the method, object will implement the overriden method; if it isn't, it will implement the method in superclass. Using overriding, implement polymorphism. The rules for overriding, the method must has the same arguments and return types. Overloading, however, is not the same as an overridde method. Its return types and arguments list must different, and the access level can be varied. Let's see two overload methods: public void setUniqueID(String theID){...};public void setUniqueID(int ssNumber){...}. They have different arguments, but they're both have no return, are they legal?
These are not serious polymorphism, I just consider whether these relationship between superclass and subclass is the basis of interface. Tomorrow I will read the interfaces and abstract classes, maybe i'll more clearlier.Bother your time,I'm so sorry!Thanks a lot!
- Inheritance and polymorphism 1
- Inheritance and polymorphism 2
- Inheritance and Polymorphism
- Inheritance and polymorphism
- JavaScript OOP (Polymorphism and Inheritance)
- Java学习笔记(11)Inheritance and Polymorphism
- ABAP OO INHERITANCE & POLYMORPHISM
- 封装,capsulation,&&继承,Inheritance,&&多态,polymorphism
- Python-Beyond the Basics--Inheritance & Subtype Polymorphism
- Java - Constructors and Polymorphism
- Polymorphism【1】
- C++ Template and Inheritance
- inheritance and virtual
- Name Lookup and Inheritance
- Name Lookup and Inheritance
- Inheritance and virtual functions
- Question of interfaces and polymorphism
- 关于java Polymorphism and cast
- flash与后台数据交换方法整理2-Flash Remting篇
- flash与后台数据交换方法整理3-WebService篇
- flash与后台数据交换方法整理4-XMLSocket篇
- NHibernate的关联映射(one-to-one,one-to-many,many-to-many)以及cascade分析
- 编码字符集与Java -Java World乱码问题根源之所在。 ZZ
- Inheritance and polymorphism 1
- Window.open()使用
- 汉字拼音的一个解决方法
- 申请成功,开张,纪念一下!
- php里去除html标记的函数
- P264Decoder Recent News
- Web服务互操作开发的十大要点
- 恶搞的NVIDIA驱动
- 测试