Suppose we want to model several different physical bookshelves full of books. W
ID: 3903598 • Letter: S
Question
Suppose we want to model several different physical bookshelves full of books. Which of the following would represent the best structure in Java?
a. a Book class, where each book is an object, and a Shelf class, where each bookshelf is an object
b. a Book class, where each book is an object, and a HashSet of Book objects, where each Set represents a bookshelf
c. a Book class, where each object represents a book along with the details of the shelf it is in
d. a Shelf class, where each object represents the bookshelf and all of its books
Explanation / Answer
Suppose we want to model several different physical bookshelves full of books.
Which of the following would represent the best structure in Java?
Answer: B
A Book class, where each book is an object, and a HashSet of Book objects, where each Set represents a bookshelf
Reason :
Because suppose a Book is a class in this you can take each book in the class as a object and if you
use HashSet you can store the books from objects and so each hash set represnts a bookshelf..
Thanks Have a great day.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.