Here is an outline for a working class OldCellPhone that has no errors (you may
ID: 3769483 • Letter: H
Question
Here is an outline for a working class OldCellPhone that has no errors (you may see this exact class several times in this exam): class 0ldcellPhone static public final int MIN-CAP 10; static public final int MAX-CAP 1000; static public final string DEFAULT-DSCR "(generic phone)"; private String description; private int memCapacity; private boolean camera; private boolean gps; public void setCamera( boolean hascam ) { camera hascam; } public void setGps( boolean hasGps ) { gps = hasGps; } public oldCel1Phone() this(DEFAULT_DSCR, MIN_CAP, false, false); public oldCel1Phone (String dscr, int mem, boolean cam, boolean gp) // not shown public String toString() // not shown public boolean setMemCapacity(int mem) // not shown Two of the methods have a return type of voidExplanation / Answer
Answer for Question is Below:
The intent of Mutator are set the data of a class variable no need to pass the boolean argument so no need to retuen anything because of the void statement.
"Accessor" and "Mutator" are just fancy names fot a getter and a setter. A getter, "Accessor",
returns a class's variable or its value. A setter, "Mutator", sets a class's variable or its value.
Option A,B and C Correct for this Question..
Option A)These methods are mutators .i.e their names and intent to modify private data members camera and/or gps
Option B)The void retuen types of these mutators does not pose a problem since it is impossible for a boolean
passed in to illegal..so..on
Option C) this is a mistake, because if the client passes an illegal boolean argument down to either method,
there is no way to report that fact back to the client via return type value ..since it is void type
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.