Don\'t have much time, help Please!!! REally appreciate it. C++ Thank You QUESTI
ID: 666319 • Letter: D
Question
Don't have much time, help Please!!! REally appreciate it. C++
Thank You
QUESTION 1:
The usual purpose of a constructor is to initialize the member variables of a class.
Select one:
a. TRUE
b. FALSE
Question 2
In C++, operator- comes in two overloaded forms, one that takes one argument and one that takes two arguments.
Select one:
a. TRUE
b. FALSE
Question 3
In C++, programmers can use a class to create a large number of variables of that type.
Select one:
a. TRUE
b. FALSE
Question 4
For every class, C++ will supply a single, no-argument constructor whose implementation will be empty.
Select one:
a. FALSE
b. TRUE
Information
The next few questions deal with the class definition (.h file) shown below. The class Blockbuster represents a popular Hollywood movie.
#include <string>
using namespace std;
namespace cs52 {
class Blockbuster{
public:
Blockbuster( int length, string title, string star );
friend bool equal( const Blockbuster & b1, const Blockbuster & b2 );
int getLength();
string getTitle();
string getPlace();
void setTitle( string title );
void setPlace( string place );
void setLength( int length );
private:
int my_Length; // feature length in minutes
string my_Title; // feature title
string my_Star; // leading actor or actress
};
}
Question 5
Which of the following statements is a valid way to create a Blockbuster object?
Select one:
a. cs52::Blockbuster b( 100, "Rambo", "Sylvester Stallone" );
b. std::Blockbuster b( 100, "Rambo" );
c. cs52::Blockbuster b;
d. std::Blockbuster b( 100, "Rambo", "Sylvester Stallone" );
Question 6
Which of the following parts of your program have access to the member variable my_Title directly without calling a method?
Select one:
a. All of the above choices have access to the variable my_Title directly without calling a method
b. Driver code like void main() {...}
c. Only methods within the class Blockbuster itself
d. Methods within classes other than Blockbuster
Question 7
What is the correct function definition when the function equal gets implemented in Blockbuster's implementation (.cpp) file?
Select one:
a. bool Blockbuster::equal(const Blockbuster & b1, const Blockbuster & b2)
b. friend bool Blockbuster::equal(const Blockbuster & b1, const Blockbuster & b2)
c. bool friend Blockbuster::equal(const Blockbuster & b1, const Blockbuster & b2)
d. bool equal(const Blockbuster & b1, const Blockbuster & b2)
Question 8
Sally the Programmer intends to write a method body of the getter method:
string Blockbuster::getTitle( )
Which of the following would be the correct implementation?
Select one:
a. myTitle( );
b. title = my_Title;
c. my_Title = title;
d. return( my_Title );
Question 9
Suppose you decide to overload the == operator in the class Blockbuster. What is the valid function declaration for the operator == that belongs in the class implementation (.cpp) file shown above?
Select one:
a. bool operator ==(const Blockbuster & b1 )
b. bool operator ==(const Blockbuster & b1, const Blockbuster & b2)
c. operator ==(const Blockbuster & b1, const Blockbuster & b2)
d. bool operator Blockbuster::==(const Blockbuster & b1, const Blockbuster & b2)
Information
The next few questions deal with the class definition (.h file) shown below. The class SummerVacation represents a trip taken somewhere.
#include <string>
using namespace std;
class SummerVacation {
void pack();
public:
int getLength();
double getCost();
string getPlace();
SummerVacation( int length, string place, double cost );
private:
void relax();
int my_Length;//days traveled
string my_Place; //place traveled to
double my_Cost; //how much was spent
};
Question 10
Which of the statements below is true about the constructor of the class SummerVacation?
Select one:
a. None of the above is correct about the constructor of the class SummerVacation
b. The constructor for the class SummerVacation requires exactly one argument
c. There is only one public constructor for the class SummerVacation
d. The class SummerVacation provides multiple, overloaded constructor methods
Question 11
In the class SummerVacation, how many public methods variables does it define?
Select one:
a. 3
b. 4
c. 5
d. 0
Question 12
Which of the statements below is true about the method pack?
Select one:
a. It is a method that requires an argument be passed by the calling code.
b. It is a public method of the class SummerVacation.
c. It is a private method of the class SummerVacation.
d. It is a method which can be called from driver code.
e. None of the above is correct about the method pack.
Question 13
In the class SummerVacation, how many constructors does it define?
Select one:
a. 4
b. 2
c. 0
d. 1
Question 14
In the class SummerVacation, how many private member variables does it define?
Select one:
a. 5
b. 4
c. 0
d. 3
Question 15
In the class SummerVacation, how many public member variables does it define?
Select one:
a. 3
b. 2
c. 0
d. 1
Question 16
Which of the statements below is true about the method getCost?
Select one:
a. It is a method which cannot be called from driver code.
b. It is an accessor method of the class SummerVacation.
c. It is a mutator method of the class SummerVacation.
d. It is a method that requires an argument be passed by the calling code.
e. None of the above is correct about the method getCost.
Question 17
Every object stores its own individual copy of all the member variable's defined by its class.
Select one:
a. TRUE
b. FALSE
Question 18
Lacking a public or private declaration, members or methods in a class will be treated as if they were marked private.
Select one:
a. FALSE
b. TRUE
Question 19
The access modifiers public and private can be listed many times within a class' header (.h) file.
Select one:
a. TRUE
b. FALSE
Question 20
In this course, we compared a class many times to the everyday things we interact with. In this way, a class and an object are similar to
Select one:
a. a fishtank and a particular fish inside a fishtank
b. an integer variable and a double variable
c. the blueprints for a house (which can be used to create many different similar houses) and a house
d. a student in a particular course and the teacher of that course
Question 21
A class' constructors are all defined to return nothing, not even void.
Select one:
a. TRUE
b. FALSE
Question 22
Which of the statements below is correct about cin?
Select one:
a. cin is a Class
b. cin is a Namespace
c. cin is a Method of an Object
d. cin is an Object
Question 23
In this course, we compared a class many times to the everyday things we interact with. In this way, we compared int main() code which interacts with a class and its methods to
Select one:
a. the data (properties) things have
b. the actions (verbs) things do
c. the brand (supplier) who made it
d. the driver (consumer) who used it
Question 24
The mutator ("setter") methods of a class are typically marked with the const modifier.
Select one:
a. TRUE
b. FALSE
Question 25
In the declaration:
int i = 10;
int myArray[ i ];
is a valid array declaration in C++.
Select one:
a. FALSE
b. TRUE
Question 26
Which of the following are correct in describing the statement: #include "SodaCan.h" and what it does?
Select one:
a. this is a preprocessor command that is found at the top of other C++ files
b. this statement is used by any file that wants to work with the classes declared inside that FlashDrive.h file
c. this statement performs textual substitution
d. All of the choices above are correct
Question 27
Within a single class definition (.h file), the public and private access modifiers can be listed any number of times.
Select one:
a. FALSE
b. TRUE
Question 28
Which of the statements below is correct about std?
Select one:
a. std is a Namespace
b. std is a Class
c. std is a Method of an Object
d. std is an Object
Question 29
The accessor ("getter") methods of a class can never be marked with the const modifier.
Select one:
a. TRUE
b. FALSE
Question 30
Given an object o, C++ programmers use the operator -> to reference the members and methods of that object.
Select one:
a. FALSE
b. TRUE
Question 31
In this course, we compared a class many times to the everyday things we interact with. In this way, we compared the class designer to
Select one:
a. the actions (verbs) things do
b. the driver (consumer) who used it
c. the brand (supplier) who made it
d. the data (properties) things have
Explanation / Answer
Question 1:
A constructor is a function of a class which is used for initializing the objects of the class. The name of the constructor is similar to the class name.
Hence, the answer is a-‘True’.
Question 2:
The operator overloading in C++, is used to overload the operator in order to provide the user defined meaning to the operator. The overloading function for ‘-’operator takes in both forms with one argument and with two arguments.
Hence, the answer is a-‘True’.
Question 3:
In C++, a class is a collection of the data which relates to a single object type. The default access modifiers for a class are private.
Hence the answer is b-‘False’.
Question 4:
The default constructor of a class in C++ contains no arguments and does not contain any code for implementation. Every class provides a single default constructor.
Hence, the answer is a-‘True’.
Question 5:
The valid way of creating an object to the constructor is,
std::Blockbuster b(100,“Rambo”, “Sylvester Stallone”);
Hence, the correct answer is d.
Question 6:
The methods within the class Blockbuster have an access to member variable my_Title because it is a private variable.
Hence, the correct answer is c.
Question 7:
In the Blockbuster class the definition of function equal is,
bool equal(const Blockbuster &b1, const Blockbuster &b2)
Hence, the correct answer is d.
Question 8:
The method body for string Blockbuster::getTitle()is my_Title=title;
Hence, the correct answer is c.
Question 9:
Within the class Blockbuster the function declaration for operator overloading is,
bool operator==(const Blockbuster &b1,const Blockbuster &b2)
Hence, the correct answer is b.
Question 10:
The constructor of the class SummerVacation as the constructor contains 3 arguments, and another three public methods. Hence, the answer is option a.
Question 11:
In the class SummerVacation there are 3 public method variables such as getlength(), getCost(), getPlace(). Hence, the answer is option a.
Question 12:
The method pack does not contain any access specifier. So, the default access modifier is private. The variables or methods which are declared as private are accessible on to that class. Hence, the answer is option b.
Question 13:
The class SummerVacation consists of one constructor SummerVacation( int length, string place, double cost );
Hence, the answer is d.
Question 14:
The class SummerVacation consists of 3 private variables my_Length, my_Place, my_Cost. Hence, the answer is d.
Question 15:
The class SummerVacation consists of no public variables . Hence, the answer is c.
Question 16:
The getCost() is one of the access method for class SummerVacation. Hence, the answer is b.
Question 17:
Every object stores its own individual copy of all the member variable's defined by its class. Hence, the answer is a.
Question 18:
When the members of class are not declared as either public or private they are treated as private by default.
Hence, the answer is b.
Question 19:
The access modifiers can be used for only time in a header file. Hence, the correct answer is b.
Question 20:
The comparison of classes to the everyday things is represented by option a.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.