Question: 2- Consider the following program: public class Product { private int price; public void setPrice (int theprice) price = thePrice; public class Specialproduct extends Item

2- Consider the following program: public class Product { private int price; public void setPrice (int theprice) price = thePrice; public class Specialproduct extends Item { private int discount; public void setDiscount (int theDiscount) { discount = theDiscount; }} public class Main public static void main(String[] args) { Special Product product = new Specialproduct(); }) Which of the following compiles without a problem? Why? a. product.discount = 20; b. product.setDiscount(20); C. product.setPrice(50)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
