Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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(stdiDStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started