The mutator methods are sometimes called ___ getters accessors setters None of t
ID: 3822172 • Letter: T
Question
The mutator methods are sometimes called ___ getters accessors setters None of the above Which method is called automatically when an object is created? Accessor method Mutator method Constructor method Destructor method When using a logical AND (or a logical OR), are the expressions to both sides of the && (or always evaluated? Please explain. Using a loop, write a program that reads in exactly five integers and outputs the sum. A value that is part of a function header is called a(n) ___ argument initialize parameter referenceExplanation / Answer
1. Text files are what type of files?
Random Access files.
2. What do the following statements accomplish?
ifstream thefile; //Declares an input file stream.
theFile.open("myFile.txt", ios::in); //The file name should be specified in quotes as a string.
//So, the file will be opened for input stream.
Opens a myFile in read mode.
3. When a file is opened in the append mode, the file pointer is positioned ___.
At the end of the file. When the file is opened in append mode, the file pointer
points to the end of the file, so that text will be appended at the end.
4. The is_closed function returns what kind of data type?
It returns a boolean value (bool), if the file is closed will return true, and false otherwise.
12. The mutator methods are sometimes called:
setters. It will mutate (i.e., update) the values of the private variables of the class.
13. Which method is called automatically when an object is created?
Constructor methods are called automatically, when the object is created.
2. When using a logical AND (or a logical OR), are the expressions to both sides of the
&& (or ||) always evaluated? Please explain.
No. This is what we call as short circuiting.
AND will hold true only when both the conditions hold true.
So, when the first expression is evaluated to false, there is no point of proceeding to second expression.
The same way, OR will hold true if atleast one condition holds true.
so, when the first expression evaluates to true, irrespective of the second expression, the result is true.
3. Using a loop, write a program that reads in exactly five integers and outputs the sum.
int value; //Reads value into this variable.
int sum = 0; //Assigns sum to 0.
for(int i = 0; i < 5; i++) //This loop runs for 5 times, for i values 0, 1, 2, 3, and 4.
{
cout << "Enter the value: ";
cin >> value; //Reads the value.
sum += value; //Adds the read value to sum.
}
cout << "The sum of the entered 5 elements is: " << sum << endl;
14. A value that is part of a function header is called a
arguments.