nerdexam
Oracle

1Z0-851 · Question #89

Given: 11. public enum Title { 12. MR("Mr."), MRS("Mrs."), MS("Ms."); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String last, String first) {…

The correct answer is A. Mr. John Doe. See the full explanation below for the reasoning.

Question

Given: 11. public enum Title { 12. MR("Mr."), MRS("Mrs."), MS("Ms."); 13. private final String title; 14. private Title(String t) { title = t; } 15. public String format(String last, String first) { 16. return title + " " + first + " " + last; 17. } 18. } 19. 20. public static void main(String[] args) { 21. System.out.println(Title.MR.format("Doe", "John")); 22. } What is the result?

Options

  • AMr. John Doe
  • BAn exception is thrown at runtime.
  • CCompilation fails because of an error in line 12.
  • DCompilation fails because of an error in line 15.
  • ECompilation fails because of an error in line 20.

How the community answered

(30 responses)
  • A
    83% (25)
  • C
    10% (3)
  • D
    3% (1)
  • E
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice