Public static void main(String argv) what is wrong in the above main declaration?

This question is related to Oracle Interview

Showing Answers 1 - 16 of 16 Answers


  • Sep 25th, 2006

The signature of the main method should be public static void main (String argv[])Iin your question the argument passed to main() is String object, it should always be an String array.


  • Dec 10th, 2010

Any java program is execution is started from main() method .so the main(String[] argv) is the main indication for JVM.In the given question "[]" is missing so the program is compiled but not executed.

  Was this answer useful?  Yes


  • Jul 19th, 2014

java is a case sensitive language so every statement should be declared as according to the syntax in main method local variable of type array you should declare [].

  Was this answer useful?  Yes


  • Dec 5th, 2014

public static void main(string argv) is question but we have to write (string args[]) this is correct

  Was this answer useful?  Yes


  • Jan 6th, 2015

As I can see this the P is capital in Public which is wrong.
As Java is case sensitive we should always user public which is a key word in java and not Public.

  Was this answer useful?  Yes


  • Jan 28th, 2015

The main method argument passed as an argument. But here that is like that.

  Was this answer useful?  Yes


  • Feb 6th, 2015

argument passed must be an array of string. Here it is just a string

  Was this answer useful?  Yes


  • Mar 4th, 2015

  1. public static void main(Strings args[])

  2. this the write to decleare main method

  Was this answer useful?  Yes


  • Mar 10th, 2015

I think Strings is wrong, because there is no Strings keyword in java. It can be (String [] args) or (String args[])

  Was this answer useful?  Yes


  • Mar 20th, 2015

You must pass a String array.
Ex : public static void main(String a[])

  Was this answer useful?  Yes

Gorakh Bhavar

  • Mar 25th, 2015

You must pass the String array not String variable. In java array Special property length that specifies the the array size dynamically.
In above line use a String variable and JVM cant find the main method it will throw following error

Error: Main method not found in class --, please define the main method as: public static void main(String[] args)

  Was this answer useful?  Yes


  • Jul 5th, 2015

public Modifier "P" is wrong. It must be small and must pass String[] as a parameter in main method.

  Was this answer useful?  Yes

Sowmyashree Megalamane Vasudevappa

  • Sep 11th, 2015

We need to pass array of strings to the main method

  Was this answer useful?  Yes


  • Dec 18th, 2015

public static void main(String args[]) is the signature

  Was this answer useful?  Yes


  • Apr 20th, 2016

Should contain string[] as argument

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions