Polymorphic method in Constructor (Java)

前端 未结 4 2065
温柔的废话
温柔的废话 2021-02-08 09:46

Class A calls the public method f() in the Constructor. Class B overrides method f() with its own implementation.

Suppose you inta

4条回答
  •  不知归路
    2021-02-08 09:49

    You're correct, that is the way it works. It's not recommended practice though, because somebody who inherits from your class can unintentionally break it.

提交回复
热议问题