Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

  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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions