Question: Build a new Book class(Book.java). This class will be a sub-class of Product. So it will inherit all the properties of Product(productId, description and price).

Build a new Book class(Book.java). This class will be a sub-class of Product. So it will inherit all the properties of Product(productId, description and price). Also add 4 new properties: title, author, publisher and isbn. A total of 7 properties. Create this class, make sure to add 2 constructors, all set and get methods, a display() method, and a toString method. Then use main to test out this class.

Main Code

Book b1;

b1 = new Book(k77, TextBook, 69.00, Intro to Java, Jones, APress, 9888771212);

b1.display(); //prints all 7 properties

=================================================================================

import java.util.*; import java.lang.*; import java.io.*;

class Product { private String pid; private String description; private double price; Product(String pid,String description,double price){ this.pid=pid; this.description=description; this.price=price; } Product(){ pid="0"; description=""; price=0; } void display(){ System.out.println("PRODUCT ID : "+this.pid); System.out.println("Description : "+this.description); System.out.println("Price : "+this.price); } public static void main (String[] args) throws java.lang.Exception { Product p1; p1=new Product("k77","Blender",69.00); p1.display(); } }

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!