main method is a standard method used by JVM to execute any java program(Java SE). - Why main method is public?

Q

main method is a standard method used by JVM to execute any java program(Java SE). - Why main method is public?

✍: Guest

A

To call by JVM from anywhere main method should be public.

If JVM wants to call our method outside of our package then our class method should be public.

package instanceofjava;

public MainDemo{

public static void main(String [] args){

}

}

2015-07-01, 529👍, 0💬