Given:



and the code fragment:

Which statement is true?

A. The program prints true.
B. The program prints false.
C. A compilation error occurs. To ensure successful compilation, replace line n1 with:

D. A compilation error occurs. To ensure successful compilation, replace line n2 with:

題解

Book類別覆寫了equals方法,當兩個Book物件的name欄位邏輯相同時,則這兩個物件也符合邏輯上的相同。

所以b1和b2變數所參考到的Book物件,有邏輯上的相同,會輸出「true」。