12. Consider the following class definitions. public class Person { private String name; public String getName() { retur
Posted: Thu May 05, 2022 1:09 pm
12. Consider the following class definitions. public class Person { private String name; public String getName() { return name; } private String author; private String title; private Person borrower; public Book (String a, String t) ( author = a; title = t; borrower = null; public void print Details () { System.out.print("Author: "1 + author + " Title: " + title); if (/* missing condition */) { System.out.println(" Borrower: " + borrower.getName()); } } public void setBorrower (Person b) { borrower = b; } } public class Book {
Which of the following can replace /* missing condition */ so that the print Details method CANNOT cause a run-time error? I. !borrower.equals (null) II. borrower != null III. borrower.getName() != null (A) I only II only (C) III only (D) I and II (E) II and III
Which of the following can replace /* missing condition */ so that the print Details method CANNOT cause a run-time error? I. !borrower.equals (null) II. borrower != null III. borrower.getName() != null (A) I only II only (C) III only (D) I and II (E) II and III