public class A extends P {
    /* Note: You can use the same variable
       name as in a parent class (or interface) and switch it from
       non-static to static variable or vice versa.
       But it is TERRIBLE style. You should never do this knowingly!

       In particular, the compiler accepts the following two lines: 
     int sv;
     static int v = 31;
    */
  

    /*  But you cannot hide an instance method defined in
        a parent class with a static method. 
        So the compiler rejects this:
    public static P m() { return this; }
    */

    /*  And you cannot override a static method defined in
        a parent class with an instance method.
        So the compiler rejects this:
    public void sm() { System.out.println("D'Oh"); }
    */

    // Here is a new method to exercise super.mem and this.mem
    public void newMethod() {
      int v=99;

      // To locate the target of a bare reference, like v, check for
      // local variables and method parameters first...
      System.out.println("A: newMethod: local v = "+v);

      // You can skip the local variables and parameters by using this...
      System.out.println("A: newMethod: this.v = "+this.v);

      // You get the parent class's v (or its inherited v) using super.v... 
      System.out.println("A: newMethod: super.v = "+super.v);

      System.out.println("A: newMethod: calling this.m()");
      this.m();  // Just use m(), for Pete's (your TA's) sake....
      // But the point of this example is to illustrate that 
      // 'this' does not change the way methods are looked up, it
      // works like a standard reference of type A to the current object.
      // That is, we still get the bottom-most m() in this object.

      System.out.println("A: newMethod: calling super.m()");
      super.m();
      // We start looking for m() in the parent class P of the current object.
      // and we DO NOT do dynamic method lookup.
      
      System.out.println("A: newMethod is done.\n");
     
    }
} // end of class A definition
