Java core: interview question 1. Explain public static void main(String [] args) { }

 public: public is an access modifier, which is used to specify who can access this method, in this it specifies public which means any class can access this method.

static: static is non access modifier, in this case it identifies this method is class-based (no instance of the class is needed to access this method). If main() is not made static the compiler throws an error because main() is called first by JVM before any objects are made.

void: it is the return type of the method. Void indicates the method will not return any value.

String [] args: It is the parameter passed to the method, in this case it is an array of Strings.

Comments

Popular Posts