Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

What are the advantages of passing arguments by reference?


  1.    Changes to parameter values within the function also affect the original arguments.
  2.    There is need to copy parameter values (i.e. less memory used)
  3.    There is no need to call constructors for parameters (i.e. faster)
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned

None.


Question 2.

When our function doesn't need to return anything means what will we use/send as 

parameter in function?


  1.    void
  2.    blank space
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> blank space

None.


Question 3.

What will happen while using pass by reference


  1.    The values of those variables are passed to the function so that it can manipulate them
  2.    The location of variable in memory is passed to the function so that it can use the same memory area for its processing
  3.    The function declaration should contain ampersand (& in its type declaration)
  4.    All of the mentioned
 Discuss Question
Answer: Option B. -> The location of variable in memory is passed to the function so that it can use the same memory area for its processing

In pass by reference, we can use the function to access the variable and it can modify it. 

Therefore we are using pass by reference.


Question 4.

Overloaded functions are


  1.    Very long functions that can hardly run
  2.    One function containing another one or more functions inside it.
  3.    Two or more functions with the same name but different number of parameters or type.
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> Two or more functions with the same name but different number of parameters or type.

None.


Question 5.


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int operate (int a, int b)
4.
{
5.
return (a * b);
6.
}
7.
float operate (float a, float b)
8.
{
9.
return (a / b);
10.
}
11.
int main()
12.
{
13.
int x = 5, y = 2;
14.
float n = 5.0, m = 2.0;
15.
cout
  1.    10.0 5.0
  2.    5.0 2.5
  3.    10.0 5
  4.    10 2.5
 Discuss Question
Answer: Option D. -> 10 2.5

In this program, we are divide and multiply the values.
Output:
$ g++ over3.cpp
$ a.out
10 2.5


Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int Add(int X, int Y, int Z)
4.
{
5.
return X + Y;
6.
}
7.
double Add(double X, double Y, double Z)
8.
{
9.
return X + Y;
10.
}
11.
int main()
12.
{
13.
cout
  1.    11 12.1
  2.    12.1 11
  3.    11 12
  4.    compile time error
 Discuss Question
Answer: Option D. -> compile time error

None.


Question 7.

Which of the following permits function overloading on c++?


  1.    type
  2.    number of arguments
  3.    both of the mentioned
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> both of the mentioned

None.


Question 8.

In which of the following we cannot overload the function?


  1.    return function
  2.    caller
  3.    called function
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> return function

While overloading the return function, it will rise a error, So we can’t overload the return function.


Question 9.

Function overloading is also similar to which of the following?


  1.    operator overloading
  2.    constructor overloading
  3.    destructor overloading
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> constructor overloading

In constructor overloading, we will be using the same options availed in function overloading.


Question 10.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
void print(int i)
4.
{
5.
cout
  1.    5500.263
  2.    500.2635
  3.    500.263
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 5500.263

In this program, we are printing the values and the values will be print(5) will be printed first 

because of the order of the execution.
Output:
$ g++ over.cpp
$ a.out
5500.263


Latest Videos

Latest Test Papers