In what ways are subtypes different from subclasses in usage?

后端 未结 6 1450
难免孤独
难免孤独 2020-12-08 05:40

A subtype is established when a class is linked by means of extending or implementing. Subtypes are also used for generics.

How can I differentiate subtyping from su

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 05:43

    In general, subclassing means to inherit the attributes of a parent. Subtyping merely means that operations on the supertype can be performed on the subtype. Note that subclassing is a special case of subtyping.

    in Java, interfaces represent the structure for describing what behaviors a type can exhibit, which makes it the natural representation for subtyping. Subclassing is manifested in the class hierarchy.

提交回复
热议问题