Rhombus rhomex = new Rhombus(3);
Rectangle rectex = new Rectangle(3,5);
Quadrilateral arrayOfQuadrilaterals[] = new Quadrilateral[ 10 ];
arrayOfQuadrilaterals[0] = rhomex;
arrayOfQuadrilaterals[1] = rectex;
An object of a subclass can be treated as an object of its superclass.
This can be done only when the superclass reference is actually referencing a subclass object;
otherwise Java will throw a ClassCastException runtime exception.
If they were declared private, Circle's methods would have to use Point's public get methods to access them.
If this were not done, the compiler would try to use the no-arguments Point constructor. (Why?)
But, there is none, so the compiler would generate an error.
References by Circle methods or clients to the toString method will refer to the overridden method.
A Circle method or client can refer to the Point toString method by indicating its intention with the super. prefix: super.toString().
Java waits until execution-time to decide which toString method to use (called dynamic binding).
At execution time, Java checks this, noticing that p is not a Circle object.
It consequently throws an exception, terminating the applet (because no provision was made to handle this exception).