Why is the main method static in Java?

Answer Posted / nashiinformaticssolutions

Java's main() function is static by default, allowing the compiler to call it either before or after creating a class object. The main () function is where the compiler begins programme execution in every Java programme. Thus, the main () method needs to be called by the compiler. If the main () method is permitted to be non-static, the JVM must instantiate its class when calling the function.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a void in java?

778


What is a lightweight component?

787


What are implicit objects in java?

738


Explain the JDB in depth & command line.

776


How can I right-justify a string?

836


Is it possible to compare various strings with the help of == operator?

745


What does flagged out mean?

785


What is the numeric promotion?

695


Is there any tag in htm to upload and download files?

807


Can we catch more than one exception in a single catch block?

830


Define an enumeration?

795


What are the types of inner classes (non-static nested class) used in java?

795


I want to re-reach and use an object once it has been garbage collected. Define how it’s possible?

785


What is the use of static class?

769


What is method and methodology?

838