answersLogoWhite

0

They are public because they must be accessible to the JVM to begin execution of the program. Main is the first method that would get executed in any class.

They are static because they must be available for execution without an object instance. you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static.

Or

Main is starting point of the program execution Main method is called by JVM there is no need for JVM to

create an object of the class just to access Main function

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

In java public static voidmain function denotes what?

Java's main function denotes the entry point into the execution of your program.


Can you interchange the term public and static in java?

The two are different, and independent from one another. A variable can be public, static, both public and static, or neither.


What is psvm in java?

public static void main


Can you overwrite main function in java?

You can not overwrite a static method in Java,and 'main' is a static method.so,you can't overwrite the 'main'.


Why the main function is public and static?

The main function is public because it means it needs to be called by any object. I had to check this myself but if you try to make the main function in Java private it will give you a run time error. It is static because it is indicating it is a class method and it does not need to be instantiated. Without the static keyword you would need to do something like this Main main = new Main();


What is public static final variable in java?

-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )


What is the difference between method and function in java?

A function is a piece of code that can be reused by calling its name while a method is a function that is associated with a class. In Java, functions are usually referred to as static methods.


What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.


What is the error in exception handling in java with example?

class Demo { public static void main(String s[]) { System.out.println("hello java frm Demo"); } } class Demo1 { public static void main(String s[]) { System.out.println("hello java frm Demo1"); String z={" "}; Demo.main(); } }


Static membors partispating Overwriting in java?

Static membors partispating in Overwriting in java?


Sample code in java programming?

public class Hello { public static void main (String args[]) { System.out.println("Hello World"); } }


How to Write a java program to display hello?

public class Hello{public static void main(String [] args){System.out.println("Hello");}}