Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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.