OCA Java SE 8 Mock Exam Review - OCA Mock Question 1








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); 
   } 
 } 
  1. Compile error ? main is not declared correctly.
  2. Compile error ? the variable parameters cannot be used as it is in the println method.
  3. Compile error ? someMethod is not declared as static and cannot be used in main method.
  4. The program will execute without errors.




Answer



c

Note

You cannot access an instance method from a static method.