Java OCA OCP Practice Question 2742

Question

What happens if you try to compile and run the following code:

public class Main {
   public static void main(String arguments[]) {
      someMethod(arguments);
   }
   public void someMethod(String[] parameters) {
      System.out.println(parameters);
   }
}
  • a. Syntax error - main is not declared correctly.
  • b. Syntax error - the variable parameters cannot be used as it is in the println method.
  • c. Syntax error - someMethod needs to be declared as static.
  • d. The program will execute without errors.


c

Note

You cannot access an instance method from a static method.




PreviousNext

Related