a) Write the declaration for class B. The members of the class should be as follows: m, an integer. This variable should not be accessible to code outside the class or to any class that extends class B. n,  an integer. This variable should be accessible only to classes that extends class B or are in the same package as class B. setM, getM,setN, getN. These are the mutator aand accessor methods for the member variables m and n. These methods should be accessible to code outside the class. calc. This is a public abstract method. b) Write a declaration for class D, which extends class B. The members of the class are as follows: q, a double. This variable should not be accessible to code outside the class. r,  a double. This variable should be accessible to any class that extends class D or is in the same package. setQ, getQ,setR, getR. These are the mutator aand accessor methods for the member variables q and r. These methods should be accessible to code outside the class. Calc, a public method that overrides the abstract method calc of the super. This value should return the value of q times r.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 6RQ
icon
Related questions
Question

a) Write the declaration for class B. The members of the class should be as follows:

  • m, an integer. This variable should not be accessible to code outside the class or to any class that extends class B.
  • n,  an integer. This variable should be accessible only to classes that extends class B or are in the same package as class B.
  • setM, getM,setN, getN. These are the mutator aand accessor methods for the member variables m and n. These methods should be accessible to code outside the class.
  • calc. This is a public abstract method.

b) Write a declaration for class D, which extends class B. The members of the class are as follows:

  • q, a double. This variable should not be accessible to code outside the class.
  • r,  a double. This variable should be accessible to any class that extends class D or is in the same package.
  • setQ, getQ,setR, getR. These are the mutator aand accessor methods for the member variables q and r. These methods should be accessible to code outside the class.
  • Calc, a public method that overrides the abstract method calc of the super. This value should return the value of q times r.

 

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning