interface and polymorphism

More later P209 P210

abstract class

you don’t know what it exactly is, it’s usually abstract name, such as animal, canine, feline.

abstract method

abstract class can be concrete in subclass

all abstract methods MUST be implemented by the first concrete subclass down the inheritance tree.

Object

Every class in Java extends class Object.

Object is non-abstract class

some methods are marked final so they can’t be overridden. But some methods are encouraged to be overridden, such as hashCode(), equals(), toString(). more later

equals()

hashCode (now think it as a uni0que ID) see it chapter 17

getClass()

toString() (the result has some numbers you don’t need to care about

Java is a strongly-typed language.

Object o = new Ferrari();

o.goFast();          //Not legal!

The compile knows only

It should be Object d = myDogArrayList.get(0);(Suppose that there are Dogs object in array myDogArrayList)

interface more need to learn

define

public interface Pet{}

implement

public class Dog extends Canine implements Pet{}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值