多态本质:多个对象共享同一接口 多态本质是共享接口
所谓的多态是将类似的不同实现统一到一个(组)接口的能力;
涉及到两个方面:1)抽象能力;2)面向接口(忽略载体、对象)。
Polymorphism is the ability of the programmer to write methods of the same name that do different things for different types of objects, depending on the needs of those objects.
Polymorphism is a long word for a very simple concept.
Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
The beauty of polymorphism is that the code working with the different classes does not need to know which class it is using since they’re all used the same way. A real world analogy for polymorphism is a button. Everyone knows how to use a button: you simply apply pressure to it. What a button “does,” however, depends on what it is connected to and the context in which it is used — but the result does not affect how it is used. If your boss tells you to press a button, you already have all the information needed to perform the task.
In the programming world, polymorphism is used to make applications more modular and extensible. Instead of messy conditional statements describing different courses of action, you create interchangeable objects that you select based on your needs. That is the basic goal of polymorphism.
Polymorphism results from the fact that every class lives in its own namespace. The names assigned within a class definition don’t conflict with names assigned anywhere outside it. This is true both of the instance variables in an object’s data structure and of the object’s methods:
相关文章
- 技术分享 | 接口测试中如何使用Json 来进行数据交互 ?
- falsk-restful代码通过swagger一键生成接口文档
- HDFS请求接口
- RPC接口测试技术-Tcp 协议的接口测试
- 2022年新出最火接口工具,利用apifox来测试API
- JMeter中如何实现接口之间的关联?
- 接口测试面试题,等你来看
- 使用telnet测试dubbo rpc接口
- 初识序列化和反序列化,使用BinaryFormatter类、ISerializable接口、XmlSerializer类进行序列化和反序列化
- IE接口缓存
- 《C++面向对象高效编程(第2版)》——2.2 对象接口的重要性
- Java 虚拟机编程接口JVMIT
- java接口(interface)
- TS之接口的使用
- Arduino UNO通过PCF8574串行IIC接口驱动LCD1602/LCD2004液晶屏
- 谷粒学院——Day02【环境搭建和讲师管理接口开发】
- 【UVM基础】config_db机制快速上手指南(接口传递、对象传递、调试)
- 使用jmeter+ant进行接口自动化测试(数据驱动)之一:设计jmeter脚本
- Spring中为什么继承了ApplicationContextAware接口就可以使用ApplicationContext对象?
- 接口 form-data 将对象转换为复杂url参数
- 接口 C#/Java 请求数据 form-data 的方式传输复杂对象