w Material 95 Questions and Answers
@i @i @i @i @i
Which of the following can be used to initialize an object when it is declared in an application program?
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
A. Public Member Function
@i @i @i
B. Private Member Function
@i @i @i
C. Public Constructor
@i @i
D. Private Constructor -
@i @i @i @i
@i ✅ C. @i
The default constructor takes _ argument(s)
@i @i @i @i @i
a. zero (0)@i @i
b. two (2) @i @i
c. one (1)@i @i
d. three (3) -
@i @i @i @i
@i ✅ A. @i
Suppose there is a Class named Car, which has a member function named set_make that can be used to se
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
t the make of a car object to a particular value (e.g. "Toyota", Ford", "Hyundai", etc.):
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
NOTE: Access specifiers have been omitted here because there is another question on this quiz about the
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
m.
class Car @i
{
string make; @i
void set_make(string m) @i @i
{ make = m; }
@i @i @i @i
string get_make() @i
{ return make; }
@i @i @i
};
Then in main we have the following code: @i @i @i @i @i @i @i
,int main @i
{
string value = "Toyota"; @i @i @i
Car car_obj; @i
................
return 0; @i
}
Which line of code could be inserted in main below the line Car car_obj; to call the set_make function for t
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
he car_obj object with the argument "Toyota"?
@i @i @i @i @i @i
a. set_make(car_obj->value);
@i
b. car_obj->set_make(value);
@i
c. car_obj.set_make(value);
@i
d. set_make(car_obj.value); -
@i @i @i
@i ✅ C. @i
What is the default access specifier in a class?
@i @i @i @i @i @i @i @i
A. Global @i
B.Public
C.local @i
D. private -@i @i @i
@i ✅ D. @i
Which of the following is like a blueprint or template that you can use to create things from?
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
a. funciton
@i
b. class
@i
c. constructor
@i
d. object -
@i @i @i
@i ✅ B. @i
,One of the concepts we learned about early in chapter 3 is data hiding. Which of the terms below refers to
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
data hiding? @i
A. Polymorphism
@i
B. Instantiation
@i
C. Inheritance
@i
D. Encapsulation -
@i @i @i
@i ✅ D. @i
Suppose a program has the following class and main function: @i @i @i @i @i @i @i @i @i
NOTE: Access specifiers have been omitted here because there is another question on this quiz about the
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
m.
class College @i
{
string name; @i
string get_name() @i
{ return name; }
@i @i @i
void set_name(string n) @i @i
{ name = n; }
@i @i @i @i
};
int main() @i
{
College college_obj; @i
return 0; @i
}
On which line in the above program would it be appropriate to insert the word "const" ?
@i @i @i @i @i @i @i @i @i @i @i @i @i @i @i @i
A.string get_name() @i
B. College college_obj;
@i @i
C. void set_name(string n)
@i @i @i
D. string name; -
@i @i @i @i
@i ✅ A. @i
, Which of the following can use a member initializer list?
@i @i @i @i @i @i @i @i @i
A. Get function
@i @i
B. Constructor
@i
C. Set function
@i @i
D. Object -
@i @i @i
@i ✅ B. @i
Another name for a get function in a class is what?
@i @i @i @i @i @i @i @i @i @i
A.Destructor
B. Mutator
@i
C. Constructor
@i
D.Accessor - @i @i
@i ✅ D. @i
In a UML diagram, which of the options below
@i @i @i @i @i @i @i @i
1) Describes a function that can be accessed anywhere -
@i @i @i @i @i @i @i @i @i
both inside of the class and outside of the class (such as in main)
@i @i @i @i @i @i @i @i @i @i @i @i @i @i
and
2) Returns an integer?
@i @i @i
A. +some_name(some_value: int)
@i @i
B. +some_name(): int
@i @i
C. -some_name(): int
@i @i
D. -some_name(some_value: int) -
@i @i @i @i
@i ✅ B. @i
Suppose a program has the following College class:
@i @i @i @i @i @i @i
class College @i
{
std::string college_name; @i