Inheritance in java programming
Inheritance 1. Suppose the class named DiscountSale is a derived class of a class called Sale . Suppose the class Sale has instance variables named price and numberOfItems . Will an object of the class DiscountSale also have instance variables named price and numberOfItems ? 2. Suppose the class named DiscountSale is a derived class of a class called Sale , and suppose the class Sale has public methods named getTotal and getTax . Will an object of the class DiscountSale have methods named getTotal and getTax ? If so, do these methods have to perform the exact same actions in the class DiscountSale as in the class Sale ? 3. Suppose the class named DiscountSale is a derived class of a class called Sale , and suppose the class Sale has a method with the following heading and no other methods named getTax , as follows: public double getTax() And suppose the defi nition of the class DiscountSale has a method defi nition with the following heading and no other method defi nitions for methods named getTax , as follows: public double getTax( double rate) How many methods named getTax will the class DiscountSale have and what are their headings?
Información del documento
- Subido en
- 7 de febrero de 2023
- Número de páginas
- 12
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas