001package subclass.exA; 002class M { 003 public static void main(String[] args) { 004 B o = new B(); 005 System.out.println("o.x=" + o.x); 006 o.m(); 007 } 008} 009class A { 010 public int x = 0; 011 public void m() { 012 System.out.println("In A::m() x=" + this.x); 013 this.p(); 014 } 015 public void p() { 016 System.out.println("In A::p() x=" + this.x); 017 } 018} 019class B extends A { 020 public int x = 42; 021 public void p() { 022 System.out.println("In B::p() x=" + this.x); 023 } 024}