This question might sound stupid to some, but I need to get it clear in my mind.
class J_SuperClass {
void mb_method() {
System.out.println("J_SuperClass::mb_method");
}
static void mb_methodStatic() {
System.out.println("J_SuperClass::mb_methodStatic");
}
}
public class J_Test extends J_SuperClass {
void mb_method() {
System.out.println("J_Test::mb_method");
}
static void mb_methodStatic() {
System.out.println("J_Test::mb_methodStatic");
}
public static void main(String[] args) {
J_SuperClass a = new J_Test();
a.mb_method();
a.mb_methodStatic();
J_Test b = new J_Test();
b.mb_method();
b.mb_methodStatic();
}
}
Output is:
J_Test::mb_method
J_SuperClass::mb_methodStatic
J_Test::mb_method
J_Test::mb_methodStatic
I know that dynamic binding occurs at runtime and static binding occurs at compile time. Also, for dynamic binding, the object's actual type determines which method is invoked. So my question is that in the above code, the word "static" causes static binding and hence the object's DECLARED type determines which method is invoked?