Why is the main method in the superclass executed by the JVM?

When I execute:

 java B

for the next program, why is the main superclass A called? As I understand it, static methods belong to the class level.

class A
{
    public static void main(String[] args)
    {
        System.out.println("A.main");
    }
}

class B extends A{ }
+4
source share
1 answer

Static methods are inherited by subclasses.

+1
source

Source: https://habr.com/ru/post/1666362/


All Articles