Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi lifesaver, I need help with this question. Here is an prototype for a working

ID: 663766 • Letter: H

Question

Hi lifesaver, I need help with this question.

Here is an prototype for a working class OldCellPhone that has no errors (you may see this exact class several times in this exam):

Two of the methods have a return type of void.

Check the true statements (there may be more than one):

Thanks!!

A. This is a mistake, because if the client passes an illegal bool argument down to either method, there is no way to report that fact back to the client via a return value (since their return types are void.)
B.
Even though their return types are void, either one of these method definitions can still return a bool as a functional return to the client. C. These methods are mutators, i.e, their name and intent is to modify private members camera and/or gps. D. The void return types of these mutators does not pose a problem since it is impossible for a bool passed-in to be illegal; we don't have to test, and we don't have to return a bool response to the client, because if the client passes in a bool, it will naturally be either true or false, so no test is needed and the return can always be void. E. The client could call either method by passing the literal false as its argument.

Explanation / Answer

C is correct as these methods are mutators. A mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter (also known as an accessor), which returns the value of the private member variable.

Option D is also correct. Void can be easily used here.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote