Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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):

... is usually slower for each search than a simple linear search.
... requires a pre-sorted array in order to work.
... is usually faster for each search than a simple linear search.
... requires more code and logic than a simple linear search.
... does a sort as part of the search algorithm.

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.

True
False

question 25.

Which are true about instance variables of a class (check all that apply):

They should usually be declared private.
Mutators should protect them by filtering bad parameter values before assigning those values to them.
Loop counters and other helper variables should be declared as instance variables so that such counters and helpers don't have to be re-declared local to every member method, individually.
Member instance methods of the same class must use mutator methods to modify their values.
Member instance methods of the same class must use this-> before their names in order to access them.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

How is slaked lime powder prepared ?

Answered: 1 week ago

Question

Why does electric current flow through acid?

Answered: 1 week ago

Question

What is Taxonomy ?

Answered: 1 week ago

Question

1. In taxonomy which are the factors to be studied ?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago