ですから、私はこの冬にプログラミング試験を受けています。私の課題の1つは、プログラミングの例を使用せずに、拡張機能とは何かを説明することです。
今、私はそれが何であるかを知っていますが、言葉で説明するのは難しいと思いますが、どのように説明しますか?Plane
あなたがextends のように、これはあなたがクラスの一部であり、あなたのオブジェクトだけが見ることができる追加情報をクラスに追加できることを意味Vehicle
します。
どう説明しextends
ますか?
The extends
keyword in Java has several roles, and it depends on what you extends
. If C
is the entity you wish to extend.
You cannot extend it at all if C
is a non abstract
class and is final
;
If C
is a non-final, non-abstract class:
C
which are not declared final;If C
is an abstract class, and you provide a concrete (ie, non abstract) implementation of it:
abstract
in the extended class;abstract
;If C
is an interface:
interface
extending another; you cannot implement a class extending an interface (that is implements
).And, more generally, you can implement several interfaces but only extend one class/abstract class (Java does not have multiple inheritance).
Answer certainly to be edited, feel free to add comments/questions/etc
You can find examples all around you..... eg:Animals and different variety of animals Vehicles, with different vehicles having some common properties and some specific properties. Shapes with common properties like area, perimeter etc, where different shapes calculate these functions differently.