当前位置:网站首页>Abstract encapsulation inheritance polymorphism
Abstract encapsulation inheritance polymorphism
2022-07-29 06:18:00 【Plum juice】
Catalog
Inherit
Inheritance is extension A subclass is an extension of the parent class
Inheritance only supports single inheritance
As long as the subclass inherits the parent class Have all the methods of the parent class
super Be careful :
1. super Call the constructor of the parent class , Must be in the first... Of the construction method
super Must only appear in a subclass's method or constructor !
3. super and this Cannot call constructor at the same time !
this:
Different objects represented :
this: Calling the object itself
super:
Represents the application of the parent object
Premise
this: You can use without inheritance
super: Can only be used in inheritance conditions
Construction method
this() : The construction of this class
super(): Construction of parent class !
rewrite
: It has nothing to do with attributes It's all about rewriting methods

Rewrite should have inheritance relationship Subclass override parent method
1 Same method name
2 Same parameter list
3 The range of modifiers can be expanded But you can't shrink
polymorphic
One A The type handle can point to the address of the object of its own class , It can also point to the address of any descendant class object

instanceof

边栏推荐
猜你喜欢

Huawei cloud 14 day Hongmeng device development -day1 source code acquisition
![寒假集训总结 (1.23~1.28) [第一梯队]](/img/cf/2f86ecc23bfe6d96ad0429c785663a.png)
寒假集训总结 (1.23~1.28) [第一梯队]

CS4344国产替代DP4344 192K 双通道 24 位 DA 转换器

【软件工程之美 - 专栏笔记】17 | 需求分析到底要分析什么?怎么分析?

LeetCode #344.反转字符串

LeetCode #3.无重复字符的最长子串

HR must ask questions - how to fight with HR (collected from FPGA Explorer)

Ml9 self study notes

智慧能源管理系统解决方案

FPGA based: moving target detection (supplementary simulation results, available)
随机推荐
Ml self study notes 5
顺序表和链表
无符号右移
LeetCode #35.搜索插入位置
【软件工程之美 - 专栏笔记】14 | 项目管理工具:一切管理问题,都应思考能否通过工具解决
智能温度控制系统
2022暑初二信息竞赛学习成果分享2
基于51单片机ADC0808的proteus仿真
基于stm32的四针OLED显示
NoClassDefFoundError 处理
给二维表添加时间序列索引
【RoboMaster】从零开始控制RM电机(2)-CAN通信原理及电调通信协议
基于51单片机的DAC0832波形发生器
Based on STM32: couple interactive doll (design scheme + source code +3d drawing +ad circuit)
滑动窗口 Leetcode 76.最小覆盖子串(困难) 76.76. MinimumWindow Substring (Hard)
基于51单片机的直流电机调速系统(L298的使用)
防爆倾角传感器应用于LNG液化天然气安全作业
噪声传感器工作原理是什么?
Hal library learning notes-11 I2C
【软件工程之美 - 专栏笔记】13 | 白天开会,加班写代码的节奏怎么破?