nerdexam
Oracle

1Z0-809 · Question #118

1Z0-809 Question #118: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #118. The question stem and answer options stay visible for context.

Question

Given the code fragments: public class Book implements Comparator<Book> { String name; double price; public Book () { } public Book (String name, double price) { this.name = name; this.price = price; } public int compare(Book b1, Book b2) { return b1.name.compareTo(b2.name); } public String toString() { return name + ":" + price; } } // and List<Book>books = Arrays.asList(new Book ("Beginning with Java", 2), new Book ("A Guide to Java Tour", 3)); Collections.sort(books, new Book()); System.out.print (books); What is the result?

Options

  • A[A Guide to Java Tour:3, Beginning with Java:2]
  • B[Beginning with Java:2, A Guide to Java Tour:3]
  • CA compilation error occurs because the Book class does not override the abstract method compareTo().
  • DAn Exception is thrown at run time.

Unlock 1Z0-809 to see the answer

You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Full 1Z0-809 Practice
Given the code fragments: public class Book implements... | 1Z0-809 Q#118 Answer | NerdExam