OCA Java SE 8 Building Blocks - OCA Mock Question Building Block 9


Which of the following legally fill in /*here*/ so you can run the main() method from the command line and make Main class runnable?

public class Main{
   public static void main(/*Here*/)  {
  1. String[] _names
  2. String[] 1
  3. String abc[]
  4. String _Names[]
  5. String... $n
  6. String names
  7. None of the above.


A, C, D, E.


A is correct because it is the traditional main() method signature and variables may begin with underscores.

C and D are correct because the array operator may appear after the variable name.

E is correct because varargs are allowed in place of an array.

B is incorrect since variables are not allowed to begin with a digit.

F is incorrect because the argument must be an array or varargs.