Question: QUESTION 9 Given below is a class that represents a Book with three attributes: author, title and publishDate. public class Book{ private String author, title;

 QUESTION 9 Given below is a class that represents a Book

QUESTION 9 Given below is a class that represents a Book with three attributes: author, title and publishDate. public class Book{ private String author, title; private Date publishDate; Book(String s, String r, Date vX author = s; title = r; publishDate = v; } public String author(){return author;} public String title(){return title:} public Date publishDate (){return publishDate;} public String toString(){return author+" "+title+""+ publishDate;} } Your task is to write the following method for the Book class: (a) equals, that returns true if two instances of the Book class have the same Author and Title. (6 marks) Page 8 of 14 (b) hashCode, that returns a hash code for an instance of the class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!