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?
Written for
- Institution
-
Harvard University
- Course
-
Programming in java
Document information
- Uploaded on
- February 7, 2023
- Number of pages
- 12
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
Also available in package deal