|
Authored by: Anonymous on Saturday, May 05 2012 @ 06:55 AM EDT |
If anything inheritance is a function of the JVM (and maybe possible just a
little bit of the javac)
It is a syntactical convenience/sugar for the Java Programming language.
Classes do not inherit anything.
Classes describe the inheritance/implementation characteristics they would like
instances of the Objects created from Classes to have.
Class extends (one only) Class implements (one or more) Interfaces
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a Java rule. It is the Java inheritance rule. It is the only place where
inheritance occurs, there is no package inheritance.
Objects when instantiated from Classes, do not inherit anything, inheritance is
a conceptual idea in OO programming how it is actually implemented is a whole
different beast: example:
Dog extends Animal implements makeNoise
When instantiated from a Class definition, (i.e when your program runs and says
make me a new Dog) it does not get you a new "blob" that is an
Dog+Animal+NoiseMaker
It gets you a Dog blob
It gets you an Animal Blob.
The Dog blob, has a pointer to the Animal blob.
(think literally, like an Arrow from the Dog pointing *AT* the Animal,
"this is my Animal"
It is trivially easy to make all Dogs *share* the *same* Animal blob, so you
have many Dog blobs, but only one Animal Blob in your running program, in many
cases this is actually what you want.
The Dog blob has all the functions/methods that are listed by makeNoise.
(and if it doesn't your program wont even start).
makeNoise has nothing, it is *ONLY* a list of names that you *MUST* use *ALL* of
if you intend to implement makeNoise.
It is not "inheritance" in the form of you got blue eyes from your
mother,
"Inheritance" in OO programming is just a word used that loosely
encapsulates some of the concepts.
Using conveniently descriptive words that conjures up the idea of a family
tree with characteristics spreading/shared down the tree is where lawyers get
their chance to smear knowledge/fact/understanding/law to their convenient point
of view.[ Reply to This | Parent | # ]
|
|
|
|
|