当前位置:网站首页>Abstract methods and interfaces

Abstract methods and interfaces

2022-06-12 05:00:00 なんでもないゃ

Abstract methods are methods that have no concrete implementation , There is no method body , use abstract modification ;

An abstract class is a class that cannot be instantiated , That is, you cannot create objects ;

There can be abstract methods in an abstract class , There can also be non abstract methods , A class with abstract methods must be an abstract class ;

After an abstract class is inherited, it must override all abstract methods , The actual meaning of abstract classes is not to create objects but to be inherited , Abstract classes are mandatory and normative for subclasses ;

Interface : More abstract than abstract classes , The methods in the interface are all abstract methods , Properties are constants , use private static final modification , It can be omitted ; stay Java8 After that, static methods are supported in the interface 、 Method of default permission ,Java9 Then support private methods ;

Interface supports multiple inheritance , Classes can only be inherited singly , Class can implement multiple interfaces , Interface makes up for the defect that a class can only inherit ;

Inner classes are divided into ordinary inner classes , Static inner class , Local inner classes , Anonymous inner class ;

原网站

版权声明
本文为[なんでもないゃ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010622133578.html