Is it possible to overload methods across classes? I tried out this code, and it works fine:
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException {
// code that performs some calculations
return a;
}
float methodTwo( char a, int b ) {
// code that performs other calculations
float f= 0;
return f;
}
}
public class Test11 extends Super {
public static void main(
String args[]) {
Test11 t11 = new Test11();
t11.methodTwo(5);
}
void methodTwo(int f){
System.out.println("Overloaded method: "+f);
}
}
Output:
Overloaded method: 5
Does this mean that the compiler takes methodTwo() in class Test11 as an overloaded method? If I change the header of
t11.methodTwo to "float methodTwo( char x, int z )" does it mean that the compiler now takes t11.methodTwo as an overriding method?
<confused> Thanks in advance