Question: This is the previous code: public class Testmain { public static void main ( String [ ] args ) { Product objProduct = new Product
This is the previous code:
public class Testmain
public static void mainString args
Product objProduct new ProductGeneric Product", ;
ElectronicsProduct objElectronicsProduct new ElectronicsProductLaptop;
System.out.printlnProduct information: ;
System.out.printlnobjProduct;
System.out.println
Electronic product information: ;
System.out.printlnobjElectronicsProduct;
class Product
private String name;
private double priceRange;
public ProductString name, double PriceRange
this.name name;
this.priceRange priceRange;
public double getPriceRange
return priceRange;
public String toString
return "Name: name Price Range: $ priceRange;
class ElectronicsProduct extends Product
private int warrantyPeriod;
private double powerConsumption;
public ElectronicsProductString name, double priceRange, int warrantyPeriod, double powerConsumption
supername priceRange;
this.warrantyPeriod warrantyPeriod;
this.powerConsumption powerConsumption;
public int getWarrantyPeriod
return warrantyPeriod;
public double getPowerConsumption
return powerConsumption;
@Override
public String toString
return super.toString Warranty period: warrantyPeriod years, Power consumption: powerConsumption"watts";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
