|
Authored by: Ed L. on Saturday, May 05 2012 @ 02:13 AM EDT |
A class called "molecule" could
inherit from a class called
"chemical" but also from a class called "atom".
Not in Java it
can't. Java is strictly single-inheritance. :)
Okay, so its a nit. But the
general answer remains that inheritance is a subclass-superclass relationship
between classes that might or might not cross package boundaries.
And yes,
the judge is doing quite well.
--- Real Programmers mangle their own
memory. [ Reply to This | Parent | # ]
|
|
Authored by: Anonymous on Saturday, May 05 2012 @ 03:14 AM EDT |
In spite of the questions suggesting the judge's thinking is taking off on a
tangent, the answers are very simple.
A class is a type of thing. A mail order system may have an object called
Address. A package is just a collection of classes. It binds related classes
together. You could have a Geography package that contains the Address
class, the LatLong class, and other related classes in a neat parcel. The
package also creates separate namespaces so an Internet package could
also contain an Address class without it getting mixed up with the
Geography one. I can't really think of any case in Java outside the package
declaration where a package reference is used in isolation. import
java.lang.*; is a reference to multiple classes.
The blunt answer to the first question is that the reason you can't inherit
packages is that it doesn't make sense. Packages have no functionality
themselves outside the classes they contain, so there is nothing to inherit in
the first place. Also, inheritance exists between classes, not within a class.
That too would be a silly concept.
As for the question about inheritance resulting from the subclass-
superclass feature of object oriented programming (not just Java), they are
effectively synonyms. Inheritance is the process of creating a subclass from
an existing class that is then referred to as its superclass. Inheritance does
not "result from" the subclass-superclass feature. Inheritance is the
subclass-superclass feature [ Reply to This | Parent | # ]
|
|
Authored by: BJ on Saturday, May 05 2012 @ 01:49 PM EDT |
I'm with you -- but don't you think there's no such thing as 'wrong questions'
-- just 'wrong answers'.
My point: part and parcel of being 'unknowing' is asking 'wrong
questions'.
Btw., among the wrong answers we should count all those answers
that are right but that are nevertheless incomplete (esp. those that
mean to obfuscate -- often for a reason).
bjd
[ Reply to This | Parent | # ]
|
|
|
|
|