Page 1 of 1

12. Consider the following class definitions. public class Person { private String name; public String getName() { retur

Posted: Thu May 05, 2022 1:09 pm
by answerhappygod
12 Consider The Following Class Definitions Public Class Person Private String Name Public String Getname Retur 1
12 Consider The Following Class Definitions Public Class Person Private String Name Public String Getname Retur 1 (32.68 KiB) Viewed 35 times
12 Consider The Following Class Definitions Public Class Person Private String Name Public String Getname Retur 2
12 Consider The Following Class Definitions Public Class Person Private String Name Public String Getname Retur 2 (19.47 KiB) Viewed 35 times
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