Several small knowledge of Java confuse

Several small knowledge of Java confuse

1, the configuration of the code block
(1) effect: to initialize the object, when the object performs the establishment, preferentially executed in the constructor
distinction configuration code block constructor and (2):

  • Code block is configured to initialize a unified common to all the different objects
  • Constructor initializes the object corresponding to

2, Kun k = new Kun () operation in memory

(1)将Kun.class文件加载进内存中
(2)如果k定义在主方法中,则就会在栈空间开辟一个变量空间k
(3)在堆内存给对象分配空间
(4)对对象中的成员进行默认初始化
(5)对对象中的成员进行显示初始化
(6)调用构造代码块对对象进行初始化
(7)调用构造方法对对象进行初始化,对象初始化完毕
(8)将对象的内存地址赋值给k变量,让k变量指向该对象

3, Math class
without constructors, methods are static

4, making the API
the API (spelling): Application Program Interface Application Programming Interface.
Content (1) class needed documentation comments.
(2) using the javadoc tool in the JDK \ bin directory.

格式:javadoc -d 目录 -author -version kun.java

5, the difference between this and super
(1) this: on behalf of the class object reference
(2) super: parent representative of storage space

6, inner classes can only access the local variables are final modified

7, the difference between abstract classes and interfaces
(1) abstract class can only inherit sheets
interfaces can achieve more than to avoid multiple inheritance limitations.
(2) characteristics of data abstract class:

  • Member variables: variables or constants may be
  • Members of the method: the method can be abstract or non-abstract methods
  • Constructors: constructors have

Data Features (3) interface:

  • Member variables: Constant public static final modification of default
  • Member method: an abstract method, modify the default public abstract
  • Constructor: no constructor

(4)

  • Abstract class is defined in the inheritance hierarchy of common functions
  • Interface is defined extensions inheritance hierarchy
Published 66 original articles · won praise 7 · views 4667

Guess you like

Origin blog.csdn.net/weixin_44717095/article/details/104791367