Question: Can someone verify if this program prints out 6 different flavors of ice cream? package com.shop.icecream; // Parent class of IceCream public class SoftAndSweetIceCreamShop {
Can someone verify if this program prints out 6 different flavors of ice cream?
package com.shop.icecream; // Parent class of IceCream public class SoftAndSweetIceCreamShop { protected double price; protected String choices; /* * Parameterized constructor */ public SoftAndSweetIceCreamShop(double price, String choices) { super(); this.price = price; this.choices = choices; } // toString method @Override public String toString() { return "SoftAndSweetIceCreamShop [price=" + price + ", choices=" + choices + "]"; } } package com.shop.icecream; //Child class of SoftAndSweetIceCreamShop class public class IceCream extends SoftAndSweetIceCreamShop { /* * Parameterized constructor */ public IceCream(double price, String choices) { super(price, choices); super.price = price; super.choices = choices; } } package com.shop.icecream; //Child class of IceCream class public class MilkShake extends IceCream { /* * Parameterized constructor */ public MilkShake(double price, String choices) { super(price, choices); super.price = price; super.choices = choices; } } package com.shop.icecream; //Child class of IceCream class public class Kulfi extends IceCream { /* * Parameterized constructor */ public Kulfi(double price, String choices) { super(price, choices); super.price = price; super.choices = choices; } } package com.shop.icecream; //Child class of IceCream class public class SoftServe extends IceCream { /* * Parameterized constructor */ public SoftServe(double price, String choices) { super(price, choices); super.price = price; super.choices = choices; } } package com.shop.icecream; public class DriverClass { public static void main(String[] args) { MilkShake milkShake = new MilkShake(300, "MilkShake"); Kulfi kulfi = new Kulfi(400, "Kulfi"); SoftServe softServe = new SoftServe(500, "SoftServe"); System.out.println("******************************Output********************************"); System.out.println(milkShake); System.out.println(kulfi); System.out.println(softServe); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
