Ask Question

Consider a Rational class designed to represent rational numbers as a pair of ints, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two ints), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private?

A. because they will never be used

B. because they will only be called from methods inside Rational

C. because they will only be called from the constructor of Rational

D. because they do not use any of the Rationalinstance data

E. This is incorrect; they should be declared as public

+2
Answers (1)
  1. 17 July, 17:26
    0
    Option B is the correct answer to the following question.

    Explanation:

    Because the data members and the member functions are declared with the private access modifier so they are unable to access from outside the class even they are the data members or the member functions. then, all the members of the class can only call through the other method of relational then, they has to be declared with the private access modifier.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider a Rational class designed to represent rational numbers as a pair of ints, along with methods reduce (to reduce the rational to ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers