MCQ on Function Overloading and Default Arguments in C++

MCQ on Function Overloading and Default Arguments in C++ with answers and explanations for placement tests and job interviews. This C++ MCQ on Function Overloading is useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our C++ Function Overloading and Default Arguments quiz (C++ Function Overloading and Default Arguments Multiple Choice Questions ) focuses on all areas of the C++ Function Overloading and its concept. We will regularly update the MCQ on the C++ Function Overloading and Default Arguments and the most interesting thing are that questions come in a random sequence. So every time you will feel new questions.

You may have come across several C++ courses during your search for learning the C++ language. Our team of experts has carefully analyzed some C++ courses for you. You can check the courses, Trial of some courses is free.

 

Guideline of MCQ on Function Overloading and Default Arguments in C++:

This MCQ on Function Overloading and Default Arguments in C++ is intended for checking your knowledge of C++ Function Overloading. It takes 30 minutes to pass the C++ quiz on Function Overloading. If you don’t finish the C++ Function Overloading and Default Arguments quiz within the mentioned time, all the unanswered questions will count as wrong. Every unanswered question will count as wrong. MCQ on Function Overloading and Default Arguments in C++ has randomization features that give you a new question set at every attempt.

In this MCQ on Function Overloading and Default Arguments in C++, we have also implemented a feature that does not allow the user to see the next question or finish the quiz without attempting the current C++ Function Overloading and Default Arguments quiz.

1 votes, 5 avg

You have 30 minutes to take the MCQs on Function Overloading and Default Arguments in C++

Your time has been Over.


C++ Function Overloading and Default Arguments MCQ

C++ MCQ

MCQ on Function Overloading and Default Arguments in C++

1 / 13

What is the output?

#include <iostream>

using namespace std;
class Test
{
public:
    Test()
    {
        cout << "Test default constructor\n";
    }
    Test( Test &o )
    {
        cout << "Test&\n";
    }
    Test( const Test &co )
    {
        cout << "const Test&\n";
    }
    Test( volatile Test &vo )
    {
        cout << "volatile Test&\n";
    }
};

int main()
{
    Test o1;
    Test o2( o1 );
    const Test o3;
    Test o4( o3 );
    volatile Test o5;
    Test o6( o5 );
}

 

2 / 13

Code will compile?

#include<iostream>

void fun(const int& a)
{
    std::cout << "fun(const)" << std::endl;
}

void fun(volatile int& a)
{
    std::cout << "fun(volatile)" << std::endl;
}

void fun(const volatile int& a)
{
    std::cout << "fun(const volatile)" << std::endl;
}

int main()
{
    const int a = 0;
    const volatile int b = 0;
    volatile int c = 0;

    fun(a);
    fun(b);
    fun(c);

    return 0;
}

 

 

3 / 13

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

4 / 13

What will be the output of the following C++ code?

#include <iostream>
using namespace std;

void display(int i)
{
    cout << i;
}

void display(double  f)
{
    cout << f;
}

int main()
{
    display(5);

    display(500.263);

    return 0;
}

 

5 / 13

What is the output of the below code?

#include<iostream>
using namespace std;

void fun(const int data)
{
    cout << "fun(const int) called ";
}

void fun(int data)
{
    cout << "fun(int ) called " ;
}

int main()
{
    const int data = 10;
    fun(data);
    return 0;
}

 

6 / 13

Output?

#include<iostream>
using namespace std;
 
int fun(int x = 0, int y = 0, int z)
{  return (x + y + z); }
 
int main()
{
   cout << fun(10);
   return 0;
}

 

7 / 13

Which of the following in Object-Oriented Programming is supported by Function overloading and default arguments features of C++.

8 / 13

Which of the following overloaded functions are NOT allowed in C++?

 

1) Function declarations that differ only in the return type

int fun(int x, int y);
void fun(int x, int y);

2) Functions that differ only by static keyword in return type

int fun(int x, int y);
static int fun(int x, int y);

3)Parameter declarations that differ only in a pointer * versus an array []

int fun(int *ptr, int n);
int fun(int ptr[], int n);

4) Two parameter declarations that differ only in their default arguments

int fun( int x, int y); 
int fun( int x, int y = 10);

 

9 / 13

Output of following program?

#include <iostream>
using namespace std;
 
int fun(int=0, int = 0);
 
int main()
{
  cout << fun(5);
  return 0;
}
 
int fun(int x, int y) { return (x+y); }

 

10 / 13

What will be the output of the following C++ code?

#include <iostream>
using namespace std;

int Add(int X, int Y, int Z)
{
    return X + Y;
}


int main()
{
    cout << Add(5, 6);

    return 0;
}

 

11 / 13

What is the output?

#include<iostream>
using namespace std;

class Test
{
public:

    void fun() const
    {
        cout << "fun() const called " << endl;
    }
    void fun()
    {
        cout << "fun() called " << endl;
    }
};

int main()
{
    Test obj1;
    const Test obj2;

    obj1.fun();
    obj2.fun();

    return 0;
}

 

12 / 13

Function overloading is also similar to which of the following?

13 / 13

What is the output of this C++ program?

void square (int *x)
{
  *x = (*x)++ * (*x);
}
void square (int *x, int *y)
{
   *x = (*x) * --(*y);
}
int main ( )
{
  int number = 30;

  square(&number, &number);
  cout << number;
  return 0;
}

 

Your score is

The average score is 0%

0%

Recommended Articles for you:

Leave a Reply

Your email address will not be published. Required fields are marked *