Hi, lifesaver! Would appreciate the help! Stuck on this question :( Here is an p
ID: 663768 • Letter: H
Question
Hi, lifesaver! Would appreciate the help! Stuck on 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):
A programmer decides to add a method addMemory() whose job it will be to increase the private int memCapacity by an amount specified by the client as long as the new, increased memory capacity after increasing it 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 correctly defined, a client could add 30 units of memory to the OldCellPhone object, myCell, by using the syntax:OldCellPhone::addMemory( myCell(30) );
D. If correctly defined, a client could add 30 units of memory to the OldCellPhone object, myCell, by using the syntax:OldCellPhone::addMemory( 30 );
E. If correctly defined, a client could add 30 units of memory to the OldCellPhone object, myCell, by using the syntax:myCell.addMemory( 30 )
Explanation / Answer
For this question the true answers are:
B. This should be a static method.
&
C. If correctly defined, a client could add 30 units of memory to the OldCellPhone object, myCell, by using the syntax:OldCellPhone::addMemory( myCell(30) );
Static methods are the ones which where all objects of a particular type might have behavior that is not dependent at all on member variables..
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.