Documente Academic
Documente Profesional
Documente Cultură
Fact: EVERY class we create is in fact a subclass of a class called Object (with a capital O!).
Yes, I see the irony in that. Any class in Java has a single parent class. We can either state the
name of our parent class explicitly, or our parent class is Object if we do not say.
public class Animal { // Child class of Object
versus
public class Mammal extends Animal { // Child class of Animal class.
Relationship of subclasses to parent class: EVERY object of the subclass type IS A object of
the parent class type as well just a specialized version of one.
Meaning of this: instance variables from the parent class are found in all object of the child class
and any method defined by the parent class can be performed by objects of the sub class (some
exceptions to this will be explained later).
A child class can replace an instance method stated in the parent class by giving an alternate
(more appropriate ) version in the subclass this replacement version would have the SAME
header as the one given in the parent class. This is not method overloading, but rather method
overriding.