CSE2305 - Object-Oriented Software Engineering
Self Assesment Questions
For each question choose the single response which best answers the question, or which completes the statement most accurately.
Question 52: | What is the general syntax for doing output in a C++ program? |
cout << var1 << var2; |
cout >> var1 >> var2; |
var1 >> var2 >> cout; |
var1 >> cout << var2; |
cout <<var1,var2>>; |
Question 53: | What is the general syntax for doing input in a C++ program? |
cin << var1 << var2; |
cin >> var1 >> var2; |
var1 >> var2 >> cin; |
var1 >> cin << var2; |
cin <<var1,var2>>; |
Question 54: | What is the purpose of the cin object? |
To represent an input stream |
To represent an output stream (i.e. one which we can put values in) |
To represent the process of input |
To act as a receptacle to put values in |
None of the above |
Question 55: | What is the purpose of endl in C++ I/O. |
It is used at the end of output statements instead of a semicolon. |
It instructs the output object to print a newline character, but not to flush its buffer. |
It instructs the output object to print a newline character and then to flush its buffer. |
It instructs the output object to flush its buffer and then to print a newline character |
None of the above |
Question 56: | A function that takes and returns no arguments is specified in C++ as: |
void f(void) |
void f() |
f() |
f(...) |
f(void, ...) |
Question 57: | What is the difference between delete and delete
[] ? |
delete can only be called on scalar objects, whereas delete[] can
be called on scalar and vector objects |
There is no difference: they are different syntax versions of the same function |
There is no difference: they are different semantic versions of the same function |
delete will delete a single object, whereas delete[] deleates
multiple objects allocated as an array |
None of the above |
Question 58: | What is a "reference"? |
A synonym for "pointer" |
Another name for an object |
Another name for a type |
A way of copying objects without extra memory |
A name for any parameter to a C++ generic type |
Question 59: | Which of the following statements declares a reference named refname? |
ref refname = var&; |
int refname = &var; |
int& var = refname; |
int& refname = var; |
refname = int& var; |
Question 60: | Once a reference is declared, how can it be distinguished from the original object it references? |
They have different addresses (i.e. use the & operator) |
They have different sizes (i.e. use the sizeof() function) |
They have different types (i.e. use the typeid() function) |
They have different scopes (i.e. test for a call to their destructors) |
A reference can't be distinguished from the original object it references. |
Question 61: | What is a "reference parameter"? |
A reference which is used as an argument to a function call |
A function parameter which is a reference |
A reference which refers to a function parameter |
A parameter which is passed to a reference |
A parameter which is used to initialize a reference |
Question 62: | What are the advantages of passing arguments by reference? |
Changes to parameter values within the function also affect the original arguments. |
There is need to copy parameter values (i.e. less memory used) |
There is no need to call constructors for parameters (i.e. faster) |
All of the above |
None of the above |
Last updated: July 27, 2005