当前位置:网站首页>Application and definition of interface
Application and definition of interface
2022-04-23 03:28:00 【Aiyou coffee】
Interface characterization : Interface cannot be instantiated ; Implementation classes must implement interfaces that are all methods ; Implementation classes can implement multiple interfaces ; Variables in an interface are static constants .
How to use interfaces : Design methods as needed , Implement all methods , Use... In a polymorphic way
The process : Definition Door abstract class ( There's a door , close ), Definition Lock Interface ( locked , The lock )
To write TheftproofDoor class ( Inheritance implementation interface ) Writing test classes ( There is an anti-theft switch to unlock the door )PS: A class can implement multiple interfaces
One . You can define a new interface , use extends To inherit the existing interface
You can define a new interface , use implements To implement all the methods in an interface
You can define a new interface , use implements To implement some methods in an interface
Two .C++ Support for multiple inheritance ,Java Support for single reinheritance ;C++ The danger of multiple inheritance is that a class may inherit different implementations of the same method , Will cause the system to crash ,Java A class in can inherit only one class , But multiple interfaces can be implemented at the same time , That is, the effect and function of multiple inheritance can be realized , The danger of multiple inheritance can also be avoided
3、 ... and . Defining a class inside another class is called an inner class . PS: External classes cannot directly use members and methods of internal classes , If the external class and the internal class have the same member variables or methods, the internal class .
Default member variable or method internal class , If you want to access the member variables of an external class , need this keyword
Four . Access the inner class in the outer class
grammar : Inner class External class objects = new External class ();
External class , Inner class Inner class object = External class objects new Inner class ();
5、 ... and . Inner class Static inner class
grammar new External class . Inner class () Syntax name
External class class name , Inside Inner class object name = new External class class name . Inner class class name ();
( Use static Declared inner class , Non accessible static External properties of )
No variables in the interface are constants , Because the default final
If a class has no parent , Then its parent is Object
The phone has three interfaces : Play , photograph , Connect to the network
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619008863.html
边栏推荐
- 2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
- Why is bi so important to enterprises?
- Knowledge of software testing~
- Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer
- JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
- MySQL installation pit
- Punch in: 4.23 C language chapter - (1) first knowledge of C language - (12) structure
- List interface of collection
- C abstract class
- 打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
猜你喜欢

Super easy to use asynchronous export function of Excel

Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer

It can receive multiple data type parameters - variable parameters

Quartz. Www. 18fu Used in net core

Unity knowledge points (common core classes)

Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer

Applet - canvas drawing Poster

Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)

关于idea调试模式下启动特别慢的优化

Knowledge of software testing~
随机推荐
AWS from entry to actual combat: creating accounts
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
Idempotency practice operation, explaining idempotency based on business
2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
The query type of MySQL is very inefficient.
C-11 problem I: find balloon
The content of the website is prohibited from copying, pasting and saving as JS code
Explication détaillée des fonctions send () et recv () du programme Socket
Cefsharp stores cookies and reads cookies
Unity knowledge points (common core classes)
Applet - more than two pieces of folding and expansion logic
月薪10k-20k都无法回答的事务问题,你会吗?
Punch in: 4.23 C language chapter - (1) first knowledge of C language - (12) structure
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
MySQL之explain关键字详解
通过 zxing 生成二维码
TCP three handshakes and four waves
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer