// ---------------------------------------------------------------------- // CLASS DEFINITIONS // ---------------------------------------------------------------------- class Parent { // constructor Parent() { println("Building a Parent."); } void speak() { println("I am a Parent."); } } // use the keyword "extends" to create a child/subclass class Child extends Parent { void speak() { println("I am a Child."); } } // ---------------------------------------------------------------------- // GLOBAL VARIABLES // ---------------------------------------------------------------------- // declare a Parent object Parent p; // declare a Child object Child c; // ---------------------------------------------------------------------- // MAIN // ---------------------------------------------------------------------- void setup() { // instantiate the Parent object p = new Parent(); // instantiate the Child object c = new Child(); p.speak(); c.speak(); }