当前位置:网站首页>Can abstract classes inherit entity classes?
Can abstract classes inherit entity classes?
2022-06-09 20:56:00 【w_ rcss】
The answer is :yes!
give an example :java in object Is an entity class , Other classes, including abstract classes, mostly inherit object.
But there is a precondition that the entity class must have an explicit constructor .
What is an explicit constructor ?
First of all, understand java Inheritance : Subclasses inherit all but not the parent class constructs , A subclass can only call a parent class construct .
My personal understanding of explicit constructors is : Constructs that can be called by subclasses ( A subclass invokes a parent class construct as a prerequisite for inheritance ), There are mainly the following 3 spot .
① The parent class writes a parameterless construct , Or don't write ( If you do not write, a parameterless structure will be generated by default ) Will be called by subclasses . Subclass not write construct , By default, a parameterless construct is generated and the first sentence is declared super(); Subclasses that write constructs need to be declared in the construct super();
② The parent class writes a parameterized construct , Subclasses must have constructs and the first line of the construct declares super() And the reference ;
③ By final Modifications cannot be inherited by subclasses , By private Modifiers are not visible to subclasses , Such inheritance cannot be implemented when it cannot be called and constructed by subclasses .
therefore , The premise of inheritance is that the parent class has a construct that can be called by its children . It doesn't really matter whether it is abstract or not , The entity class inherits the abstract class and also needs a parent class construct that can be called by itself .
边栏推荐
- Typescript variable declaration
- Sort - quick sort
- Force buckle 84- the largest rectangle in the histogram (monotone stack)
- LeetCode 497. 非重叠矩形中的随机点**
- 刚学嵌入式,想问问什么是中断,中断的概念是什么
- Go calls several simple examples of kubernetes API
- 快速了解服务器IO的实现
- 力扣84-柱状图中最大的矩形(单调栈)
- C#中运算符重载的例子
- 739. daily temperature force deduction (monotonic decreasing stack)
猜你喜欢

Mysql:1062 Duplicate entry '1' for key 'PRIMARY'

力扣84-柱状图中最大的矩形(单调栈)
![[operation and maintenance department] ad domain file permission management](/img/f4/5598384b352b2335145ffa58437439.png)
[operation and maintenance department] ad domain file permission management

The browser cannot open Baidu, and others can be opened normally

搭建ngrok服务器,实现内网穿透服务,实现外网到内网的在线访问

C language implementation of simple calculator
![[tgowt] cmake to Ninja construction](/img/e9/8ce56c421ee98c0b36464fc65dd39d.png)
[tgowt] cmake to Ninja construction

03 Wireshark TCP

dump. Pcapng packet parsing

Integer ordered array lookup -- traversal and half / bisection
随机推荐
刚学嵌入式,想问问什么是中断,中断的概念是什么
numpy重复数据
es自动停止
Sort - quick sort
Extended application of C # static class
逻辑回归总结
完美数(算数借位问题)
Some small details of C for loop
『踩坑记录』IDEA导航栏工具栏添加“后退”功能按钮
开源一个 nodejs 防火墙小工具
College community management system
Who says redis can't save big keys
Some problems encountered in deploying cinder CSI plugin
Initial experience of transformation of vite lerna monorepo project
二叉搜索树
部署 cinder-csi-plugin 遇到的几个问题
编程题:统计字符串中出现次数最多的字母
Go 1.18 新特性 - 工作区
Ceisum 3D scene demo
C#关于抽象类的学习