About Core java interview questions – main() method
This Core Java Interview Questions about main() Method page providing information about the main method in the form of interview questions including the need of main method, the signature of the main method, return type etc.
What is the use of main() in java application?
main() is used to start application execution.
JVM invokes main() implicitly.
Why main() is public & static?
main() method common(static) starting point of all(public) java standalone applications.
“static” represents “common”
“public” represents “for all”.
Why is main() return type void?
JVM invokes main() method to start execution.
The main() method is not returning any information to JVM hence it is void.
“void” represents “nothing” in every programming language.
What is Method Naming Convention Rule?
“MIXED CASE AND NO SPACE”
What is Signature of method?
List of arguments(input values) of a method.
The prototype differs from Signature.
The prototype includes modifiers, return type…
What is the main() signature?
It is a String array.
Used to collect command line arguments.
We can pass arguments at command line while invoking java application.
Why do we need to set the path for JDK?
The operating system should start Computer(javac) and JVM(java) to compile and run the java application.
OS can recognize executable files (javac, java…) only if we set the path to executable files folder in OS environment variables.