Object-oriented classes and interfaces inside ---

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_44779847/article/details/102732763

1. Members inner classes: probability is not high alone
1) Sleeve class, called the Outer outside the external class, which is called the Inner internal class
2) inner class normally only to service external class, does not have visibility of external
3 ) inner class object is usually created in the outer class
4) internal classes can be accessed directly members of the outer class (including private)
internal class has implicit reference points to create its external object
eg: external class name .This.
2. anonymous inner classes:
1) If you want to create a class (derived class) of the object, and the object is created only once,
at this time do not have the class name, called anonymous inner class
2) If an anonymous inner class want to access external variable that must be final
(where required before JDK1.8, JDK1.8 you can not add the final)

Common interview questions:
Q: internal class has a separate .class do?
A:

1. Interface:
1) is a data type (a reference type)
2) defined by the interface
. 3) can contain constants and abstract methods
4) can not be instantiated
5) the interface is to be implemented / inheritance, implementation class / derived class:
All abstract interface methods must override
6) a class can implement multiple interfaces, separated by a comma
after the inheritance and if and when implemented, should inherit the implementation
7) the interface can inherit an interface

Design Rules:
1) all derived classes that are common attributes and behaviors, pumped superclass ------- pumping commonality
2) conduct all derived classes are the same, the design method for the general
conduct are all derived classes not the same, designed to abstract methods
3) the part of the derived class common behavior, interface able to get
both also in line with the principle of time, using the interface
interface is the root --------- multiple inheritance of a single extended inherited

Guess you like

Origin blog.csdn.net/qq_44779847/article/details/102732763