static 개념 질문입니다.
꽃은별
2023.04.01
public class a {
protected static int fun() {
return 2;
}
public static void main(string[] args) {
a a = new v();
system.out.println(a.fun());
}
}
class v extends a {
public static int fun() {
return 1;
}
}
//
fun메소드가 static이 아닐경우에는 다형성에 의해서 1이 출력되는데요, static으로 선언하니까 상위메소드의 fun이 호출되네요. static일 경우에 어떤식으로 동작해서 이렇게 되는건지 궁금합니다. 그리고, static 메소드에서는 super나 this를 사용하면 컴파일 에러가 뜨던데 무엇때문에 static 메소드내에서 super, this의 사용을 막아놓은건지 궁금하네요. 답변좀 부탁드려요~.