Question
question 21. Here is an prototype for a working class OldCellPhone that has no errors (you may see this exact class several times in this
question 21.
Here is an prototype for a working class OldCellPhone that has no errors (you may see this exact class several times in this exam):
class OldCellPhone { public: static const int MIN_CAP = 10; static const int MAX_CAP = 1000; static const string DEFAULT_DSCR; private: string description; int memCapacity; bool camera; bool gps; public: OldCellPhone(string dscr = DEFAULT_DSCR, int mem = MIN_CAP, bool cam = false, bool gp = false); string toString(); bool setMemCapacity(int mem); void setCamera( bool hasCam ) { camera = hasCam; } void setGps( bool hasGps ) { gps = hasGps; } };
A programmer decides to make the static DEFAULT_DSCR mutable, removing its const status, as in:
static string DEFAULT_DSCR;
A mutator is added for this member. Any string whose length is at least 2 characters will be acceptable as a new DEFAULT_DSCR. Check the true statements (there may be more than one correct answer):
The mutator for this member will be an instance method. |
The mutator for this member will be a static method. |
If the mutator takes a string parameter, newDefault, a reasonable definition would be: if ( newDefault.length() > 0 ) return false; DEFAULT_DSCR = newDefault; return true; |
If the mutator takes a string parameter, newDefault, a reasonable definition would be: if ( newDefault.length() < 2 ) { this->newDefault = DEFAULT_DSCR; return false; } this->newDefault = newDefault; return true; |
If the mutator takes a string parameter, newDefault, a reasonable definition would be: if ( newDefault.length() < 2 ) return false; DEFAULT_DSCR = newDefault; return true; |
question 22.
The statements
Card *card1, *card2, *card3, myCard; card1 = new Card; card2 = card1;
will cause how many card objects to be instantiated? (only one correct choice):
2 |
3 |
4 |
none
question 23. Consider a binary search algorithm as described in the modules. Assume that the array to be searched is pre-sorted, so that sort is not part of the search algorithm. Searching an array using a binary search (check all choices that apply):
question 24. A static class method might take one or more objects of its class as parameters -- or it might take none -- depending on the purpose of the method.
question 25. Which are true about instance variables of a class (check all that apply):
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started