0% found this document useful (0 votes)
23 views

Core-Java Importance of Main Method in JAVA:: Public Static Void Main (String Args) ( - Instructions - )

The document discusses the main() method in Java. The main() method serves as the entry point for Java applications and must be declared as public static void to allow the JVM to access and execute the code within the method. Declaring main() as public allows it to be accessed throughout the Java application and system, while static means it can be called without requiring an instance of the class to be created.

Uploaded by

nagkkkkk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Core-Java Importance of Main Method in JAVA:: Public Static Void Main (String Args) ( - Instructions - )

The document discusses the main() method in Java. The main() method serves as the entry point for Java applications and must be declared as public static void to allow the JVM to access and execute the code within the method. Declaring main() as public allows it to be accessed throughout the Java application and system, while static means it can be called without requiring an instance of the class to be created.

Uploaded by

nagkkkkk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CORE-JAVA

Importance of Main()method in JAVA:

The main intention of main() in java application is

1.To manage application login in java applications.

2.To define starting point and ending point to the application execution.

Syntax:

public static void main(String[] args)

----instructions-----

Note: main() method is not predefined method, it is not user defined method, it is a
conventional method implementation.

Q) What is the requirement to declare main() method" public"?

In java applications to strart applications execution jvm has to access main() method, to
access main() method scope must be available to jvm. To bring main() method scope to the
jvm we have to declare main()method as "public".

If we declare main() method as private then that main() method is available upto the
respective main class only, not to the jvm, so that jvm is unable to access main() method.

if we declare main() method as <default> then main() method is available upto the respective
package only, not to the jvm, so that jvm is unable to access main() method.

if we declare main() method as "protected " then main() method is available upto the present
package and upto the child classes available in the other packages, but not the jvm, so that
jvm is unable to access amin() method.

id we declare main method as "public " then main() method is available through out the java
application or through out the system including jvm, so that, jvm is able to access main()
method.

Note: If we declare main() method with out "public" then coplier will not raise any error, but in
jvm will provide the following messages.
JAVA6: Main method not public

JAVA7: Error: Main method not found in class Test, please defined

public static void main (....)

2Q)What is the requirement to declare main () method as "Static"?

You might also like