class A {
public void m(Number n) {
n = 5 / 3;
System.out.println("class A, method m : " + n);
}
}
class B extends A {
public void m(Double d) {
d = d / 3;
System.out.println("class B, method m : " + d);
}
}
public class MainClass {
public static void main(String args[]) {
A a = new B();
a.m(5.0);
}
}
mashenka011041, variable has type A, but the object for which variable references has type B. That`s important difference
2023 Apr 5, 8:24:42 AM
Login in to like
Login in to comment