Question: What is the relationship between class Student and class BScStudent? Why is it used? What are the advantages and disadvantages? Explain how to prevent class

 What is the relationship between class Student and class BScStudent? Why

  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.

Questioni: Consider the following classes: 1 public class Student { int stdID; String name: 4 double fees: public Student(int stdid, String name, double fees) 7 this.stdiD=stdID: 8 this.name-name: 9 this.fees=fees: 10 } 11 12e public Student 13 this(202010021, "Husain", 1000): 14 } 15 160 public double discount(double fees) 17 if fees>1000) 18 return fees*0.1; 19 else 20 return 0; 21 1 22e public double discount(int stdin) 23 if(stdID 2018) 24 return fees*0.05; 25 else 26 return 0; 27 }] public class BScStudent extends Student { 40 public double discount(double fees) return super.fees 0.15; } 5 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!