Question: QUESTION 1 A throw block is where an exception is handled an exception may be thrown a catch takes place where execution continues after an
QUESTION 1
A throw block is where
| an exception is handled | ||
| an exception may be thrown | ||
| a catch takes place | ||
| where execution continues after an exception |
10 points
QUESTION 2
Which statement is correct?
| Pointer variables are just memory addresses and can be assigned to one another without regard to type. For example: double *dPtr; int *iPtr; ... iPtr = dPtr; | ||
| One can use the & operator to extract the value that a pointer points to. Ex: int *iPtr; ... cout << &iPtr; | ||
| The declaration below declares three pointer variables of type pointer to double that is, a pointer of type (double*) double* p1, p2, p3; | ||
| You can get a pointer value to initialize a pointer variable from an object of an appropriate type with the address-of operator, &. For example: int *iPtr, iVal; iPtr = &iVal; |
10 points
QUESTION 3
Which statement is correct?
| A constructor is like a function. It can return any type value needed. | ||
| A constructor is a special kind of member function. It is automatically called when an object of that class is declared. | ||
| You can write a class that is useful with all its constructors in the private section. | ||
| A constructor is always named construct with class name attached. If the class is Foo, then the constructor name is constructFoo. |
10 points
QUESTION 4
Which is incorrect?
| When declaring several pointer variables, there must be one pointer declarator * for each pointer variable. | ||
| You can get a pointer value to initialize a pointer variable from an object of an appropriate type with the address-of operator, &. | ||
| Pointer variables are just memory addresses and can be assigned to one another without regard to type | ||
| A pointer is a variable that holds the address of some other location in memory. |
10 points
QUESTION 5
In which area of memory are dynamic variables located?
| Code | ||
| Heap | ||
| Stack | ||
| None listed |
10 points
QUESTION 6
Which is incorrect?
| There should eventually be a call to the operator delete on a pointer that points to the memory allocated by each call to new. | ||
| A function can return an array. | ||
| Dangling pointers present a problem in C++ | ||
| Dynamic variables or dynamically allocated variables in C++ are created and destroyed according to the programs needs. |
10 points
QUESTION 7
Which function declaration passes a pointer as a parameter?
| void func1(int piVal, double *pdVal); | ||
| int* func3(int piVal, double pdVal); | ||
| double func4(int &piVal, double &pdVal); | ||
| void func2(int &piVal, double pdVal); |
10 points
QUESTION 8
Which sample code program (in Blackboard->Code->6-10->Ch10) creates a dynamic array?
| Program 10.7 | ||
| Program 10.3 | ||
| Program 10.6 | ||
| None listed |
10 points
QUESTION 9
which of these declares a function pointer?
| int *calc(); | ||
| int *pt[3]; | ||
| int (*calc)(); | ||
| int &pt=num; |
10 points
QUESTION 10
A string function that returns a boolean value is
| at() | ||
| compare() | ||
| find() | ||
| empty() |
10 points
QUESTION 11
Function members of a class gain access to the calling object's members by
| a pointer to the calling object that is implicitly provided by the compiler. The name if this pointer is this. The members are prefixed implicitly by this-> as in this->membername | ||
| there is no particular mechanism, the variables just know what the calling object is and automatically refer to the calling object | ||
| a variable called self that is an alias for the calling object. This self is used to access the members of the object as in self.membername | ||
| None of the above |
10 points
QUESTION 12
If a class is named MyClass, what must the constructors be named?
| initializer | ||
| ~MyClass | ||
| MyClass | ||
| Any name the programmer wishes except the name of the class |
10 points
QUESTION 13
In class Complex, defined in Program 11.1 (Blackboard->Contents->Code->6-10->Ch11), which function is a mutator?
| imaginaryPart | ||
| assignNewValues() | ||
| showComplexValues() | ||
| Complex() |
10 points
QUESTION 14
Which statement invokes the constructor for class Complex?
| Complex a; | ||
| Complex b(6.8, 9.7); | ||
| All listed | ||
| Complex a, b(6.8, 9.7); |
10 points
QUESTION 15
Which function declaration is NOT accepting an array of ints as a parameter?
| int findMax(int *vals, int size); | ||
| int findMax(int vals[], int size); | ||
| int findMax(int **vals, int size); | ||
| int findMax(int &vals, int size); |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
