There is a code:
class Test1{
public static void main(String[] args){
System.out.println("Test1");
}
}
class Test2 extends Test1{
}
When I try to execute java Test1
I'm getting, of course, this:
Test1
But, when I try to execute java Test2
I'm still getting:
Test1
Why? In class Test2 doesn't exist main() method. And static methods don't inherited. If I'll add main() in Test2 (with string "Test2" instead of "Test1") I'll get:
Test2
I understand why I'm getting Test2 in this example. But don't understand why I'm getting Test1 if main() doesn't exist in class Test2.