Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 5

Given this enum declaration:

Examine this code:

System.out.println(Alphabet.getFirstLetter());

What code should be written at line 3 to make this code print A?

    Correct Answer: C

    The method getFirstLetter should be static to be called without an instance of the enum. Also, using A.toString() will return the string representation of the constant A, which is what should be printed. Thus, the correct code at line 3 is: static String getFirstLetter() { return A.toString(); }.

Discussion
Sa16253748596Option: C

C is true