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








Question

What would be the results of compiling and running the following class.

class test {
   public static void main() {
      System.out.println("test");
   }
}
  1. The program does not compile as there is no main method defined.
  2. The program compiles and runs generating an output of "test"
  3. The program compiles and runs but does not generate any output.
  4. The program compiles but does not run.




Answer



D

Note

The following main method

public static void main() {

should be changed to

public static void main(String[] argv) {