Simple Java Program1046 - Java Quiz Question


Which of the following is correct?

X: If we do not provide String array as the argument to the main method as shown below, then the program compiles but throws a run-time error "NoSuchMethodError".

class First
{
    public static void main()
    {
        System.out.println("Hello World");
    }
}

Y: If static modifier is removed from the signature of the main method as shown below, then the program compiles but throws a run-time error "NoSuchMethodError".
class Second
{
    public void main(String []args)
    {
        System.out.println("Hello World");
    }
}


A
X only
B
Y only
C
Both are correct
D
Both are incorrect