Question: Create a class that represents a Book object. A `Book` is described by an author, a title, and a publication year. Define the class, declare
Create a class that represents a Book object. A `Book` is described by an author, a title, and a publication year.
Define the class, declare its instance variables, and create a toString method for it. The toString method should return a String in the form: author, "Title" (year)
public class Main {
public static void main(String[] args) {
// DO NOT CHANGE THE MAIN CLASS!!!
// All your code should go into the "Book.java" file, in the Book class
Book book = new Book("Virginia Woolf", "To the Lighthouse", 1927);
Book book2 = new Book("Sheldon Axler", "Linear Algebra Done Right", 2015);
System.out.println(book);
System.out.println(book2);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
