What is the difference between the following declarations? And when are they used?
ParentClass child = new ChildClass();
ChildClass child = new ChildClass();
...if I already have this:
class ChildClass extends ParentClass {}
What is the difference between the following declarations? And when are they used?
ParentClass child = new ChildClass();
ChildClass child = new ChildClass();
...if I already have this:
class ChildClass extends ParentClass {}
 
    
    Lets say that you have a method foo() declared in ParentClass and a method bar() in ChildClass. Since ChildClass extends ParentClass - it also inherits the foo() method.  
In the first case you wouldn't be able to call child.bar(); because ParentClass doesn't have a method called bar().
Same thing applies to variables, inner classes, etc. For further information, consult the Oracle documentation.
