1. Assume that we have defined an enum type Planet and an instance memberMethod(
ID: 3867036 • Letter: 1
Question
1.
Assume that we have defined an enum type Planet and an instance memberMethod() in classSolarSystem:
Which statement has an enum-related compiler error? Assume that these are isolated statements in otherwise sensible method definitions and that there are no variables with the names MERCURY,... NEPTUNE anywhere in our program other than the ones seen above.
2.
Which describe a design in which B is a derived class of base class A? (Check all that apply.)
Class B is a HighRise, which has a minimum of five floors (stories) with stairs and elevators and utilized by government agencies, condo complexes and companies.
Class B is a CityVisualizer which will render one or more Buildings in 3D on a computer or smart phone screen.
Class B is a Automobile -- either a Car or a Truck.
Class B is a FuelInjector, a special kind of part that goes into cars and trucks.
4.
Consider the following 2-D array allocation:
Assume that we deallocate in a sensible manner using simple loop structures that would work no matter how large the array was. Check all the true statements:
5.
Which describe a design in which B is a derived class of base class A? (Check all that apply -- there may be one or more checked box.)
Class B is a Jacket.
Class B is an MensApparelItem, which is stocked and sold by a department store like Macy's.
Class B is an JacketSleeve (something that goes into a Jacket).
Class B is an InventoryItem, something a business stocks and sells to a customer. It has an item number and price.
6.
In which type of class methods is it typically necessary to filter bad arguments (either directly or indirectly with the help of validators) in order to protect private data of your class?
7.
An array of 100 elements is to be sorted using the bubble sort in the modules (the one that tests the return value of floatLargestToTop() to see if it can return "early".) Check all the true statements about the sort algorithm, i.e., the sort method and its support methods. (Check all that apply.)
It will always require at least 99 comparisons
8.
Which of the following are good candidates for instance variables for a class that you would define?
9.
If we operate bitwise on the following two decimal integers, as indicated, what are the two resulting decimal answers?
9 bitwise-or 7
9 bitwise-and 7
10.
If an instance method calls another instance method of the same class, an object must be used for dereferencing the call.
True
False
11.
Check the true statement(s)
(There is at least one correct choice, possibly more.)
12.
ClassA has a method, void methodA( ClassA aObj ), which takes, as a parameter, an object of the same ClassA.
There are no "sub-classes" involved. ClassA is the only class in the discussion and is not derived from any other user-defined classes.)
Check all the true statements. (Check all that apply):
13.
The statements
will cause how many card objects to be instantiated? (only one correct choice):
4
14.
A constructor is used to:
15.
If varA and varB are two instantiated object variables of some class, then varB = varA copies all the (shallow) data members from varA's object over to varB's object. Assume that = has not been overloaded (i.e., has its default meaning).
True
False
16.
In the following numbers, we use (D) to denote ordinary decimal notation, and (H) to denote hexadecimal notation:
Which of the following are the correct binary representation of these four numbers?
17.
A binary search of a pre-sorted array of 256 elements would take (at most) how many comparisons? (Assume the search key is the key on which the array is sorted).
[I allow for off-by-one errors in this problem, so if your prediction is within one of the posted choice below, choose it.]
18. A binary search algorithm is written (as in the modules, for example) which searches a pre-sorted array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):
[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]
A. void SolarSystem::memberMethod() { Planet myHome = EARTH; } B. void SolarSystem::memberMethod() { SolarSystem::Planet myHome = SolarSystem::EARTH; } C. int main() { SolarSystem::Planet myHome; myHome = EARTH; } D. int main() { SolarSystem::Planet myHome; myHome = SolarSystem::EARTH; if (myHome > SolarSystem::JUPITER) // ... } E. int main() { cout << SolarSystem::EARTH; }
Explanation / Answer
1. C contains an error since in myHome = EARTH; reference of EARTH is not stated in the code.
2. We have two correct options:
A is correct because a 'High Rise' is a derived class of 'Building'.
D is also correct because a 'High Rise' is a derived class of 'AutoPart'.
B is incorrect beacuse CityVisualizer is a software not Building
C is also incorrect as Automobile is not a derived class of AutoPart
4. It is a partially dynamic array having 3 rows and 5 columns.
NOTE: double * myArray[3] is not dynamic allocation and indicates that we have 3 rows
5. Only B is correct since MensApparelItem is a InventoryItem
Accordig to chegg protocol we are suppose to answer 4 subquestions, so only first 4 answered.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.