当前位置:网站首页>The difference between abstract classes and interfaces
The difference between abstract classes and interfaces
2022-07-06 13:39:00 【Wake up duck, did you program today?】
First, let's look at abstract classes , What is an abstract class ?
1、 Abstract classes don't necessarily have abstract methods , Abstract classes must have keywords abstract To modify
2、 If a class contains abstract methods , So this class must be an abstract class
3、 Abstract classes cannot be used final Embellishment stands for , Because abstract classes are used for inheritance , however final Modified representative cannot be modified , Non inheritable
The difference between interface and abstract class ?
1、 A subclass can only inherit one abstract class , But you can implement multiple interfaces
2、 Abstract classes have construction methods , Interface has no constructor
3、 Abstract classes can have common member variables , There cannot be
4、 Abstract classes and interfaces can have static member variables , But member variables in abstract classes can be of any type , The interface can only be public static final( Default )
5、 There doesn't have to be an abstract method in an abstract class , But the methods in the interface must be abstract
6、 Abstract classes can have static methods , There cannot be static methods in an interface
7、 The methods in an abstract class can be public、protected, Methods in an interface can only be public
边栏推荐
- 12 excel charts and arrays
- 西安电子科技大学22学年上学期《信号与系统》试题及答案
- Set container
- Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
- MySQL锁总结(全面简洁 + 图文详解)
- 【九阳神功】2019复旦大学应用统计真题+解析
- C语言实现扫雷游戏(完整版)
- 3. C language uses algebraic cofactor to calculate determinant
- 7. Relationship between array, pointer and array
- [during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
猜你喜欢
随机推荐
[中国近代史] 第六章测验
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
更改VS主题及设置背景图片
List set map queue deque stack
编写程序,模拟现实生活中的交通信号灯。
2. C language matrix multiplication
The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng
8. C language - bit operator and displacement operator
自定义RPC项目——常见问题及详解(注册中心)
vector
一段用蜂鸣器编的音乐(成都)
7. Relationship between array, pointer and array
MySQL锁总结(全面简洁 + 图文详解)
String abc = new String(“abc“),到底创建了几个对象
Network layer 7 protocol
Smart classroom solution and mobile teaching concept description
杂谈0516
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
3.猜数字游戏
【九阳神功】2021复旦大学应用统计真题+解析