Java OCA OCP Practice Question 533

Question

Given the following class,

which of the following calls print out Blue Jay?

Choose all that apply

public class Main { 
  public static void main(String[] name) {              
      System.out.println(name[1]); 
  } 
} 
  • A. java Main Pet Blue Jay
  • B. java Main Pet "Blue Jay"
  • C. java Main Blue Jay Pet
  • D. java Main "Blue Jay" Pet
  • E. java Main.class Pet "Blue Jay"
  • F. java Main.class "Blue Jay" Pet
  • G. Does not compile.


B.

Note

Option B is correct because arrays start counting from zero and strings with spaces must be in quotes.

Option A is incorrect because it outputs Blue.

C is incorrect because it outputs Jay.

Option D is incorrect because it outputs Pet.

Options E and F are incorrect because they output Error: Could not find or load main class Main.class.




PreviousNext

Related