abstract class 하면 다형성을 생각하게되고 처음에 abstract class 와 interface 와 혼란이 많이와서 이참에 정리를 하려고한다.

다형성(polymorphism)

다형성의 철학은 세가지가 기본이된다.
– 클래스 상속 계층구조
– 메소드 오버라이딩(재정의). 이를 통한 동적 바인딩
– 업캐스팅 후 재정이된 메소드 호출

이를 기반으로 나온것이 abstract class 와 interface 이다


Abstract classes

일부 클래스와 그 내부의 클래스는 abstract(
A class and some of its members may be declared abstract. An abstract member does not have an implementation in its class. Note that we do not need to annotate an abstract class or function with open – it goes without saying.

A class and some of its members may be declared abstract. An abstract member does not have an implementation in its class. Note that we do not need to annotate an abstract class or function with open – it goes without saying.

We can override a non-abstract open member with an abstract one

open class Polygon {
    open fun draw() {}
}
abstract class Rectangle : Polygon() {
    override abstract fun draw()
}Abstract classes
A class and some of its members may be declared abstract. An abstract member does not have an implementation in its class. Note that we do not need to annotate an abstract class or function with open – it goes without saying.
We can override a non-abstract open member with an abstract one





open class Polygon {
    open fun draw() {}
}
​
abstract class Rectangle : Polygon() {
    override abstract fun draw()
}




0