Suppose we removed the qualifier static from the method announcement() in both Sale (Display 8.1) and DiscountSale (Display 8.2). What would be the output produced by the following code (which is...



Suppose we removed the qualifier static from the method announcement()


in both Sale (Display 8.1) and DiscountSale (Display 8.2). What would


be the output produced by the following code (which is similar to the end of


Display 8.4)?


Sale s = new Sale( );


DiscountSale discount = new DiscountSale( );


s.announcement( );


discount.announcement( );


System.out.println("No surprises so far, but wait.");


Sale discount2 = discount;


System.out.println(



"discount2 is a DiscountSale object in a Sale variable.");


System.out.println(



"Which definition of announcement( ) will it use?");


discount2.announcement( );


System.out.println(



"Did it use the Sale version of announcement()?");



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here