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








Question

Given the following class, which of the following calls print out how are you?

     public class Main { 
       public static void main(String[] name) {              
         System.out.println(name[1]); 
       } 
     } 
  1. java Main Hi how are you
  2. java Main Hi "how are you"
  3. java Main how are you Hi
  4. java Main "how are you" Hi
  5. java Main.class Hi "how are you"
  6. java Main.class "how are you" Hi
  7. Does not compile.




Answer



B.

Note

In Java arrays start counting from 0 and strings with spaces must be in quotes.

Options E and F are incorrect since they add . to the class name command Main.class.