answersLogoWhite

0


Best Answer

the method of an class that can is triggered when starting a Java application e.g. by running the command: "java MyProgram"

Answer

Public is an Access Specifier,static is a keyword which illustrates that method shared along all the classes.void illustrates that this method will not have any return type.main is the method which string has an argument. Public specifier makes the method visible outside the Class and because of the static nature of the method, JVM can call this main method without instantiating the class 'MyProgram'.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Not really, even though you can have two methods with the same name(main) but you will have to have different argument list/type, and in the end the JVM will pick up the main methods with String[] as parameter, for the entry in the application.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago
  • public - so that any class can access it
  • static - so that the JVM can access it without the need to instantiate the class object
  • void - because it does not return anything
  • main - this is just the method name.
This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Actually you can have a static public void main. The java compiler or the JVM does not complain about the order in which the keywords are placed for the main method as long as all of them are there.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

The main method is the point of entry for your program. It is the method which will be executed first when you tell Java to run your program.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Yes; the Java language specification doesn't dictate the order of method modifiers, just that they must come before any other part of the method header.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

No, you cant.

Java only accepts

public Static void main

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

It is the syntax followed in java. First access specifier then return type. we should not chance the order. but we can change the order of public and static like static public void main()

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can we write static public void main in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is psvm in java?

public static void main


How to Write a java program to display hello?

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


Write a program to show the concept of recursion in java?

public class Main{ public static void main(String[] args){ System.out.println("the factorial of 5 is: " + getFactorial(5)); } public static int getFactorial(int num){ return num + getFactorial(num-1); } }


In java public static voidmain function denotes what?

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


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'.


How many types can write public static void main in java?

You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way. i.e., public static void main(String[] args) is the same as static public void main(String[] args) However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.


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(); } }


Can you have two mains in java?

Yes... We can have more than one main in JAVA... Just make the only one main method as public and other as default access specifier.... public class Test { public static void main(String args[]) { } } class Test1 { public static void main(String args[]) { } } class Test2 { public static void main(String args[]) { } } Just copy the above code and try.... Have fun in learning... :-) :) :-)


Write a Java program to generate a copy of itself?

public class S{public static void main(String[]a){String o="public class S{public static void main(String[]a){String o=%c%s%c;System.out.printf(o,34,o,34);}}";System.out.printf(o,34,o,34);}}


Is there any change by interchanging the position of main in Public static void main in java?

No. You can write it in as many ways as you want. The words public, static and void can be interchanged during the method declaration and still the main() method will continue to work in the same way. i.e., public static void main(String[] args) is the same as static public void main(String[] args) However, if you miss either of these 3 keywords from the method signature, the compiler will still let you compile the method, but it just won't be the main method that can be used to start the program execution.


Write a program in java programming language to print welcome to java programming?

public class welcome { public static void main (String args[]) { System.out.println("Welcome to Java programming"); } } There are also many "Hello World" tutorials you can find elsewhere on the internet


How do you invoke static methods?

if some method is static, then you can not call that method through the oobject of that class. but the name of the class. let us see a example: class Test { int a; int b; static void show() { System.out.println("we are in show"); } } class Main { public static void main(String args[]) { Test t=new Test(); t.show();\\thiss is an erroraneous code. because, the method "show()" is static. Test.show();\\this is correct } Arnas Sinha