当前位置:网站首页>The difference between abstract and interface interface
The difference between abstract and interface interface
2022-06-26 05:53:00 【Fog distant view】
Abstract abstract : Let's start with abstract methods , Abstract methods are not like ordinary methods , It has no method body {}、 And use abstart Keyword modification 、 And abstract methods can only be written in abstract classes ;
e.g. public void student(){...} // Common method
public abstart void student(); // Abstract method
Let's talk about abstract classes , Abstract classes are generally used as parent classes , When inheriting an abstract parent class, you must override the abstract methods of the parent class ( When the subclass is also an abstract class, there is no need to override )
Abstract methods can have constructors 、 Member variables
Interface Interface :Interface The interface is more like a “ pure ” Abstract method of , Abstract methods in an interface can be omitted abstract
, But there are no common methods in the interface , But in the JDK1.8 Start , Interface allows you to define a default method ( Method with method body )e.g. public default void student(){...}, This is equivalent to “ Common methods in interfaces ”;
No constructor is allowed in the interface ;
Members in the interface “ Variable ” Somewhat different , Not variables but constants , Must be responsible for and use in the interface public As modifier
边栏推荐
- C generic speed
- There are applications related to web network request API in MATLAB (under update)
- 适配器模式
- RIA想法
- Talk 5 wireless communication
- 新的征程
- Explore small program audio and video calls and interactive live broadcast from New Oriental live broadcast
- 机器学习 05:非线性支持向量机
- Machine learning 05: nonlinear support vector machines
- kolla-ansible部署openstack yoga版本
猜你喜欢
随机推荐
Feelings of virtual project failure
FindControl的源代码
5 minutes to learn regular expressions
Yamaha robot splits visual strings
kolla-ansible部署openstack yoga版本
cross entropy loss = log softmax + nll loss
Daily production training report (16)
类和对象的学习
售前分析
Test depends on abstraction and does not depend on concrete
Pre-Sale Analysis
BOM文档
小程序如何关联微信小程序二维码,实现二码聚合
On site commissioning - final method of kb4474419 for win7 x64 installation and vs2017 flash back
[PHP] PHP two-dimensional array is sorted by multiple fields
Sql查询时间段内容
Household accounting procedures (First Edition)
June 3 is a happy day
numpy.tile()
Sofa weekly | open source person - Yu Yu, QA this week, contributor this week