Question 39 When an array is passed to a function, it is actually ________ the a
ID: 3840284 • Letter: Q
Question
Question 39
When an array is passed to a function, it is actually ________ the array that is passed.
the starting memory address of
a copy of all the values in
the value stored in the first element of
the data type and size of
the data type and name of
2 points
Question 40
When an array is passed as an argument to a function, the function can modify the contents of the array.
True
False
2 points
Question 41
A two-dimensional array can be viewed as
two rows of values.
two columns of indexes.
a table with rows and columns.
any of the above.
none of the above.
2 points
Question 42
True/False: A one-dimensional array can only store elements of a single data type, but a two-dimensional array can hold data of two different data types.
True
False
2 points
Question 43
An array of 10 integers named arr can have its contents displayed with which of the following statements?
cout << arr;
cout << arr[];
cout << arr[10];
cout << arr[0-9];
none of the above
2 points
Question 44
If the size declarator is omitted in an array declaration
the array will contain no elements.
the array size defaults to 100 elements.
the value of each array element is set to a default value of 0.
the declaration must have an initialization list.
the array cannot be created.
2 points
Question 45
The statement
typedef int oneDArray[20];
does which of the following?
creates an array of 20 integers
makes oneDArray a copy of another 20-integer array
makes oneDArray an alias for a data type that holds 20 integers
creates a one-dimensional integer array with all elements initialized to 20
none of the above
2 points
Question 46
When an object instance is passed to a function as a constant reference
the function accesses the original object, rather than a copy of it.
the function cannot make any changes to the member variables.
it is more efficient than passing it by value.
all of the above are true.
A and B are true, but not C.
2 points
Question 47
The following statement adds a new element to the department vector at index 25:department.push_back(25);
True
False
2 points
Question 48
Assuming employee is an array of objects with a public member function named setHourlyWage, the following statement correctly calls this method for employee[2].
employee.setHourlyWage[2](20.00);
True
False
2 points
Question 49
A copy constructor is used when objects are passed by reference.
True
False
2 points
Question 50
If iter is an iterator for a map of type map<int,string>, the type of the expression iter->second is ________.
2 points
Question 51
Write the destructor prototype for the class Station.
the starting memory address of
a copy of all the values in
the value stored in the first element of
the data type and size of
the data type and name of
Explanation / Answer
Question 39
When an array is passed to a function, it is actually "the starting memory address of" the array that is passed.
Explanation:
An array is passed as a reference parameter to a function. What is actually passed is the address of its first element.
Question 40
When an array is passed as an argument to a function, the function can modify the contents of the array. : True
Explanation :
Since arrays are passed by reference that is if the function changes the value of an element in an array which is a parameter of the function then the corresponding actual array of the call will have that element changed.
Question 41
A two-dimensional array can be viewed as "a table with rows and columns."
Explanation :
2-D array contains rows and columns which can be viewed as a table.
Question 42
A one-dimensional array can only store elements of a single data type, but a two-dimensional array can hold data of two different data types. : False
Explanation :
2-D array can also store data of only one data type.
For Eg : int matrix[rows][columns];
From above we can see that array "matrix" is having only one data type ie int but can store total of rows*columns values.
Question 43
An array of 10 integers named arr can have its contents displayed with which of the following statements? "none of the above"
Explanation :
to display contents of an array named arr, we have to loop through the array.
for (int i=0; i<10; i++)
cout<<arr[i];
Question 44
If the size declarator is omitted in an array declaration "the declaration must have an initialization list."
Explanation :
when we leave the size declarator empty, there array get its size from the initialization list provided.
for example :
int arr[] = {1, 2, 3, 4};
above array, arr will have size 4 as the number of elements defined in initialization list is 4.
Question 45
The statement
typedef int oneDArray[20];
does which of the following?
"makes oneDArray an alias for a data type that holds 20 integers"
Explanation :
given statement will allow us to declare an integer array of size 20 as: oneDArray variable_name
Question 46
When an object instance is passed to a function as a constant reference : "all of the above are true."
Explanation :
Passing a class argument by value causes a copy of the class to be made which is slow and most of the time, we don’t need a copy, a reference to the original argument works just fine, and is more performant because it avoids the needless copy. We typically make the reference const in order to ensure the function does not inadvertently change the argument.
So, it satisfies all the given options : the function accesses the original object, rather than a copy of it, the function cannot make any changes to the member variables and it is more efficient than passing it by value.
Question 47
The following statement adds a new element to the department vector at index 25:
department.push_back(25);
False
Explanation :
department.push_back(25) will add 25 at the end of the vector department ie after its current last element.
Question 48
Assuming employee is an array of objects with a public member function named setHourlyWage, the following statement correctly calls this method for employee[2].
employee.setHourlyWage[2](20.00);
False
Explanation :
correct call : employee[2].setHourlyWage(20.00);
square brackets should come after employee as it is an array of objects and setHourlyWage is a method of the object class.
Question 49
A copy constructor is used when objects are passed by reference.
False
Explanation :
When we pass object by reference, we do not create a copy instead we use same object.
When we pass object by value, we need a copy constructor to copy the values form the caller to the callee.
Question 50
If iter is an iterator for a map of type map<int,string>, the type of the expression iter->second is "string"
Explanation :
Values in map are stored in key value pairs. the iterator has two components, first for key, second for value.
Question 51
Write the destructor prototype for the class Station.
Destructor :
~Station(){
//code
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.