MCQ On Functions - C++ Programming

31. A function abc is defined as
void abc(int x=0, int y, int z=0)
{
cout << x << y << z;
}
Which of the following function calls is/are illegal? (Assume h, g are declared as integers)

A. abc () ;
B. abc (h) ;
C. abc (h,h) ;
D. Both A and B

View Answer


32.
int a =1 , b=2;
a=chg(b) ;
cout << a << b ;
If the function chg is coded as
int chg(int x)
{
x = 10;
return ();
}
then

A. It results in compile-time error
B. It results in run time error
C. It prints 1 1 2
D. It prints 1 1 1

View Answer


33.
int a =1 , b=2;
a=chg(b) ;
cout << a << b ;
If the function chg is coded as
int chg(int &x)
{
x = 10;
return ();
}
then

A. It results in compile-time error
B. It results in run time error
C. It prints 1 1 2
D. It prints 1 1 10

View Answer


34.
int a =1 , b=2;
a=chg(b) ;
cout << a << b ;
If the function chg is coded as
int chg(const int &x)
{
x = 10;
return ();
}
then

A. It results in compile-time error
B. It results in run time error
C. It prints 1 1 2
D. It prints 1 1 10

View Answer


35.Choose the correct statements regarding inline functions.

A. It speeds up execution
B. It slows down execution
C. It increases the code size
D. Both A and C

View Answer


36. The compiler identifies a virtual function to be pure

A. by the presence of the keyword pure
B. by its location in the program
C. if it is equated to 0
D. None of the above

View Answer


37. If many functions-have the same name, which of the following information, if present, will be used by the compiler to invoke the correct function to be used?

A. The operator : :
B. The return value of the function
C. Function signature
D. Both A & C

View Answer


38.Which of the following parameter passing mechanism(s) is/are supported by C++, but not by C?

A. Pass by value
B. Pass by reference
C. Pass by value-result
D. All of the above

View Answer


39. If a piece of code can be implemented as a macro or as an inline function, which of the following factors favour implementation as an inline function?

A. Interacting with other components (like variables in an expression), in the correct way ..
B. Flexibility to manipulate as a pointer
C. Source code size
D. Both A and B

View Answer


40.Assume that the random number generating function - rand( ), returns an integer between 0 and 10000 (both inclusive). If you want to simulate the throwing of a die using this random function, use the expression

A. rand ( ) % 6
B. rand ( ) % 6 + 1
C. rand ( ) % 5 + 1
D. None of the above

View Answer






Also check :


Discussion


* You must be logged in to add comment.