About Question enthuware.ocpjp.ii.v11.2.3321 :
Posted: Wed Jun 26, 2019 11:48 am
I think there is a bug in this question: class Book does not have a toString() method and it is not implied like accessors are in the commented line.
When I execute the given code (after adding accessors to class Book) I get this result:
Only when I add this toString() method to class Book
I get answer 1.
When I execute the given code (after adding accessors to class Book) I get this result:
Code: Select all
[Book@87aac27, Book@3e3abc88, Book@6ce253f1]
Code: Select all
@Override
public String toString() {
return genre + ":" + title;
}