Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a- Extend the Product class by adding two derived classes child classes and subclasses): ElectricProduct - FoodProduct b-Create the main class to display the attributes

image text in transcribedimage text in transcribed

a- Extend the Product class by adding two derived classes child classes and subclasses): ElectricProduct - FoodProduct b-Create the main class to display the attributes of Foodproduct object c- And add the following main/client class: import java.time. LocalDate; public class App\{ public static void main(String[]args)\{ Product p = new Product (1234, 9.99, "water"); FoodProduct p4 = new FoodProduct(3452, 10.0, "Cheddar Cheese", LocalDate.parse("2022-06-07")); ElectricProduct p5 = new ElectricProduct (4875,30.0, "Extension cord", "220v"); \} d- Question: The Product class should not be instantiated directly as done in the first line of the main method. Change the Product class, so only concrete classes should be instantiated. What changes would you make? Hint: You'll need to change the definition of the Product class. (to be non instantiable)

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_2

Step: 3

blur-text-image_3

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

3 What are the four major aspects of an organisation culture?

Answered: 1 week ago