Question: 1. What is the relationship between class Student and class BScStudent? Why is it used? What are the advantages and disadvantages? 2. Explain how to
1. What is the relationship between class Student and class BScStudent? Why is it used? What are the advantages and disadvantages? 2. Explain how to prevent class BScStudent from changing the discount method? 3. How to use Polymorphism in the above code? Instantiate a polymorphic object in Test class and explain the mechanism and its advantages. 4. Why is (this) keyword used in Line13? Explain the process.
C 1 2 public class BScStudent extends Student { 3 40 public double discount(double fees) { 5 return super.fees*0.15; 6 } 7} 1 public class Student { 2 int stdID; 3 String name; 4 double fees; 5 60 public Student(int stdID, String name, double fees){ 7 this.stdID=stdiD; 8 this.name=name; 9 this.fees=fees; 10 } 11 12e public Student0{ 13 this(202010021, "Husain",1000); 14 } 15 160 public double discount(double fees){ 17 if(fees>1000) 18 return fees*0.1; 19 else return 0; } 220 public double discount(int stdID){ 23 if(stdiD
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
