Consider the following code, which is identical to the code discussed earlier in the opening of the subsection, “Downcasting and Upcasting,” except that we added the type cast shown in color: Sale...


Consider the following code, which is identical to the code discussed earlier in


the opening of the subsection, “Downcasting and Upcasting,” except that we


added the type cast shown in color:


Sale saleVariable;


DiscountSale discountVariable =


 new DiscountSale("paint", 15, 10);


saleVariable = (Sale)discountVariable;


System.out.println(saleVariable.toString());


We saw that without the type cast, the definition of the toString method used


is the one given in the definition of the class DiscountSale. With this added


type cast, will the definition of the toString method used still be the one given


in DiscountSale or will it be the one given in the definition of Sale?



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here