Question: 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


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
Get step-by-step solutions from verified subject matter experts
