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

Need help on this C++ question! Here is an prototype for a working class OldCell

ID: 663773 • Letter: N

Question

Need help on this C++ 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):

A programmer decides to add a method add20ToMemory() whose job it will be to increase the private int memCapacity by 20 as long as the new, increased memory capacity, after adding 20, is still <= MAX_CAP.  Otherwise, it will not touch memCapacity.

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

A. This should be an instance method.
B. This should be a static method.
C. If the programmer chose to make it an instance method, it would not need any parameters to do its job.
D. If the program chose to make it a static method, it would not need any parameters to do its job.

E. The method should be a void return type.
F. The method should have a bool return type.

I chose b but wasn't sure if it was right :(

Explanation / Answer

Answer:
The solution to the problem is, it all depends on the programmer.
Option A:True. It is true that it should be an instance method. Otherwise the int memCapacity variable cannot be accessed outside the class.
Option B: False. Instance variable memCapacity cannot be access in the static method.
Option C: True. There is no need of passing a parameter to the instance method.
Option D: False.
Option E: False. Whenever an item is added, it programmer cannot know whether the memory is out of MAX_CAP or not. So, it should contain a return value but not the void.
Option F: True. Whenever an item is added, it programmer can know whether the memory is out of MAX_CAP or not so that the programmer can add the items. So, it should contain a return type bool.

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