// Practice4.java
// contains classes P, Q, R, and Practice4
//
// Preparation for output problems on a quiz
// or exam, involving inheritance.
//
// Before you run this program, write down on paper
// what you think the complete output will be.
// Then run the program to see if you were right.
class P
{
public P() { System.out.println("P: " + this); }
public String toString() { return getClass().getName()
+ more() + " text"; }
protected String more() { return ""; }
} // class P
class Q extends P
{
public Q() { System.out.println("Q: " + this); }
protected String more() { return " more"; }
} // class Q
class R extends Q
{
protected String more() { return " more and"
+ super.more(); }
} // class R
public class Practice4
{
public static void main(String[] args)
{
P[] things = new P[3];
things[0] = new P();
things[1] = new Q();
things[2] = new R();
} // method main
} // class Practice4