Question: Java languege Ex. No:5 Classes and Objects 1. Create a new Java class named Book that has the following fields o year - The year

Java languege

Ex. No:5 Classes and Objects 1. Create a new Java class named Book that has the following fields o year - The year field is an integer data type that holds the year of publication (e.g. 2012) o Author - The author field is a String object that holds the author of the book (e.g."Jones") o Title - The title field is a String object that holds the title of the book(e.g. Programming with Java) 2. In addition, the Book class should have the following methods. o Constructor - The constructor should accept the book's year, author name, and title of the book as arguments These values should be used to initialize the book's year, author name, and title fields o Getter Methods - Write three accessor (getter) methods to get the values stored in an object's fields getYear(), getAuthor(), geTitle() Below code is a hint to get you started. public class Book { private int year; private String Author; private String Title; // Constructor public Book(int y, String A, String T) { year = y; // you figure out the next two lines } // Returns the book's year public int getYear() { return year; } // Returns the Author Name public String getAuthor() { // you figure out this one line } // Returns the Title of the book public double getTitle() { // you figure out this one line }

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!