Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago