The first time I asked a question here, I wrote in my review material that "the upper transformation object can access the overridden static method in the subclass (access to the value in the parent class)", I wrote a code, run The result is indeed this, but I don't know why?
class Father{
Father(){
System.out.println("Father");
}
void test1(){
System.out.println("Father test1");
}
static void test2() {
System.out.println("Father test2");
}
}
class Son extends Father{
Son(){
System.out.println("Son");
}
void test1(){
System.out.println("Son test1");
}
static void test2() {
System.out.println("Son test2");
}
}
public class FatherSon {
public static void main(String args[]){
Father f2=new Son();
f2.test1();
f2.test2();
}
}
operation result:
Father
Son
Son test1
Father test2