SE450: Overriding: Class methods [15/35] Previous pageContentsNext page

Class methods [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
package subclass.ex2;
public class M {
  public static void main(String[] argv) {
    (new B()).m();
  }
}
@SuppressWarnings("all")
class A {
  static void p() {System.out.println("A.p");}
  void m() {
    System.out.println("A.m");
    this.p(); // static or dynamic binding?
  }
}
class B extends A {
  static void p() {System.out.println("B.p");}
}

Previous pageContentsNext page