Docsity

CSCE 1337 Object-Oriented Programming Exercises and Questions, Exams of Advanced Education

Toggle sidebar
bg1
CSCE 1337 261 SP24 - Object Oriented
Programming 100% Verified
Call-by-reference should be used - ANSWER When the function needs to change the
value of one or more arguments
The following is legal in a void function - ANSWER True
Testing your program should be done - ANSWER As each function is developed
It is illegal to call other functions from inside a function definition. - ANSWER False
When a void function is called, it is known as - ANSWER an executable statement.
If you write a function that should use call-by-reference, but forget to include the
ampersand - ANSWER The program will run with incorrect results
A void function may not be used in an output statement. - ANSWER True
It is acceptable to have both call-by-value and call-by-reference parameters in the same
function declaration. - ANSWER True
What is wrong with the following code?int f1( int x, int y){ x = y * y; return x;int f2( float a,
float& b){ if(a < b) b = a; else a=b; return 0.0;}} - ANSWER Function definitions may not
be nested.
In a function with call-by-reference parameters, any changes to the formal parameters
will change the actual arguments passed to the function. - ANSWER True
pf2

Partial preview of the text

Download CSCE 1337 Object-Oriented Programming Exercises and Questions and more Exams Advanced Education in PDF only on Docsity!

CSCE 1337 261 SP24 - Object Oriented

Programming 100% Verified

Call-by-reference should be used -value of one or more arguments ANSWER When the function needs to change the

The following is legal in a void function - ANSWER True Testing your program should be done - ANSWER As each function is developed It is illegal to call other functions from inside a function definition. - ANSWER False When a void function is called, it is known as - ANSWER an executable statement. If you write a function that should use call-by-reference, but forget to include theampersand - ANSWER The program will run with incorrect results

A void function may not be used in an output statement. - ANSWER True It is acceptable to have both call-by-value and call-by-reference parameters in the samefunction declaration. - ANSWER True

What is wrong with the following code?int f1( int x, int y){ x = y * y; return x;int f2( float a,float& b){ if(a < b) b = a; else a=b; return 0.0;}} - ANSWER Function definitions may not be nested. In a function with call-by-reference parameters, any changes to the formal parameterswill change the actual arguments passed to the function. - ANSWER True

If you were to write a function for displaying the cost of an item to the screen, whichfunction prototype would be most appropriate? - ANSWER void display(float myCost);

A void function can return any value. - ANSWER False Given the following function declaration and local variable declarations, which of thefollowing is NOT a correct function call? nt myInt;float myFloat;char ch;void someFunction(int& first, float second, char third); - ANSWER someFunction(1, 2.0, ch); In the following function, what is passed to the first parameter?void f1( int& value1, intvalue2); - ANSWER the variable x (or its memory location)

A stub is a function that is completely defined and well tested. - ANSWER False What is the output of the following code fragments?int trial( int& a, int b){ if(b > a) { a=b;return — a; } else { return 0; }}float x=0, y=10,z;z=trial(y,x);cout << z << " " << x <<" " << y << endl; - ANSWER 0 0 10 In a function with call-by-reference parameters, the values of the actual arguments arepassed to the function. - ANSWER False

A void function can be used in an assignment. - ANSWER False Functions can return at most one value. - ANSWER True A simplified main program used to test functions is called - ANSWER A driver