Methods with differing type signatures are overloaded - not overridden. : Method Overloading « Class Definition « Java Tutorial






class A {
  int i, j;

  A(int a, int b) {
    i = a;
    j = b;
  }

  void show() {
    System.out.println("i and j: " + i + " " + j);
  }
}

class B extends A {
  int k;

  B(int a, int b, int c) {
    super(a, b);
    k = c;
  }

  void show(String msg) {
    System.out.println(msg + k);
  }
}

class Override {
  public static void main(String args[]) {
    B subOb = new B(1, 2, 3);

    subOb.show("This is k: "); // this calls show() in B
    subOb.show(); // this calls show() in A
  }
}








5.5.Method Overloading
5.5.1.Method Overloading
5.5.2.Using Method Overloading
5.5.3.Pass long parameters to overloading method
5.5.4.Primitives and overloading
5.5.5.Overloading based on the order of the arguments
5.5.6.Demonstration of both constructor and ordinary method overloading
5.5.7.Using overloaded methods to print array of different types
5.5.8.Methods with differing type signatures are overloaded - not overridden.