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 Rational instance data
E) This is incorrect; they should be declared as public
Correct Answer:
Verified
Q20: The following method header definition will result
Q21: A variable whose scope is restricted to
Q22: The software failure at the Denver International
Q23: Class Definition Ch 04-1
import java.text.DecimalFormat;
public class Student
{
private
Q24: In a UML diagram for a class
A)
Q26: Class Definition Ch 04-1
import java.text.DecimalFormat;
public class Student
{
private
Q27: Instance data for a Java class
A) are
Q28: If a method does not have a
Q29: A class's constructor usually defines
A) how an
Q30: Visibility modifiers include
A) public, private
B) public, private,
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents