QUESTION 1 A throw block is where an exception is handled an exception may be th
ID: 3859523 • Letter: Q
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 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 program’s 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);
an exception is handled
an exception may be thrown
a catch takes place
where execution continues after an exception
Explanation / Answer
As per the policy defined in chegg, we have to answer only first four question so here we have answer corresponding questions mentioned in actual query. To get the answer of rest of the question , you need to submit the question again.
QUESTION 1: A throw block is where
A throw block is where an exception may be thrown.
throw keyword is used to throw an exception from a particular line of code so that it can be caught and handle the same situation at some other place.
QUESTION 2 : Which statement is correct?
The declaration below declares three pointer variables of type pointer to double that is, a pointer of type (double*)
double* p1, p2, p3;
QUESTION 3: Which statement is correct?
A constructor is a special kind of member function. It is automatically called when an object of that class is declared.
for example plese take a look into below program. we have one constructor and one displayArea method in Square class.
when we declare line Square Object; then contructor gets invloked automatically.
#include<iostream>
using namespace std;
class Square {
// Variable Declaration
int side;
public:
//Constructor
Square(){
// Assign Values In Constructor
side=10;
cout<<"I m in Square class Constructor ";
}
void displayArea() {
cout<<" Total Square area :"<< (side * side ) << " ";
}
};
int main(){
// Constructor invoked.
Square Object;
Object.displayArea();
return 0;
}
QUESTION 4 : Which is incorrect?
Pointer variables are just memory addresses and can be assigned to one another without regard to type.
No it is not true. beacuse when we declear pointer type variable then we need to declear their variable data type also so that wherever we use it to read the address value
it can pick the correct length size address and same for storing the address. pointer type variable are speacisl variable that are used to store addresses of other variables or array.
Correct declearation of pointer type variable for each data type
int *ipp; // pointer to an integer
double *dpp; // pointer to a double
float *fpp; // pointer to a float
char *ch // pointer to character
above statment says that *ipp can hold the address of integer type variable only. we cannot assign double or float type variable address value.We need to do the typecasting if it is really needed.
QUESTION 5 : In which area of memory are dynamic variables located?
Answer : Heap
justification :
1. Code itself is nothing related to memory. it is sinmple text which complier picks and complie it and convert into executable form.
2. Stack holds only those variables which defined or declear inside any fuction. but dynamic variables can be defined or decleare in class so stack is not the correct answere.
3. Heap : Specially those variable which are created using new operator and malloc function. they always take memory in heap. heap memory structure is dependent on language to language like c, cpp and java.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.