复习《Thinking in Java》笔记一:第五、第八章笔记

 

一.重载:即同名方法不同参数;多态:同名同参方法,在具有继承关系的类中的动态选择

 

二.重载传入参数数据类型小于方法声明参数类型时,会被自动提升。char 类型会被直接提升为int。虚拟机就是用int表示char的。

 

三.static方法内部不能调用非static方法,反之可以。

 

四.对于方法局部变量,如果未初始化就调用,编译错误。成员变量则赋予默认值。

 

五.无论创建多少个对象,静态数据只占用一分存储区域。只在第一次调用的时候初始化。构造器实际也是static方法。

 

六.数组也是按引用(There are three kinds of reference types: the class types , the interface types , and the array types ,表示大小的成员length。打印数组数据。Arrays.toString(array)

 

 

七.

  1. 只有普通方法的访问是多态的,直接访问域将在编译时期解析。
  2. 静态方法的访问也没有多态。
  3. 构造函数调用顺序为积累 的成员函数、构造方法。


八. 静态成员初始化顺序

  1. 父类静态成员和静态初始化块 ,按在代码中出现的顺序依次执行
  2. 子类静态成员和静态初始化块 ,按在代码中出现的顺序依次执行
  3. 父类实例成员和实例初始化块 ,按在代码中出现的顺序依次执行
  4. 父类构造方法
  5. 子类实例成员和实例初始化块 ,按在代码中出现的顺序依次执行
  6. 子类构造方法

九. A public member may be accessed by any class or interface. A private member may be accessed only from within the class that contains its declaration. A member that is not declared public , protected , or private is said to have default access and may be accessed from, and only from, anywhere in the package in which it is declared.

A protected member of an object may be accessed only by code responsible for the implementation of that object. To be precise, a protected member may be accessed from anywhere in the package in which it is declared and, in addition, it may be accessed from within any declaration of a subclass of the class type that contains its declaration, provided that certain restrictions are obeyed.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值