Calling static methods via links is a really bad idea - this makes the code confusing.
These lines are:
B b = new A();
System.out.println(b.multiply(5,2));
System.out.println(b.multiply1(5,2));
compiled into this:
B b = new A();
System.out.println(b.multiply(5,2));
System.out.println(b.multiply1(5,2));
Note that calls do not rely on at all b. In fact, it bcan be zero. Binding is performed based on the type of compilation time b, ignoring its value at runtime.
Polymorphism simply does not happen with static methods.
source
share