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.");
"Which definition of announcement( ) will it use?");
discount2.announcement( );
"Did it use the Sale version of announcement()?");
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here