C-Plus-Plus Questions

0 votes, 0 avg
215

C-Plus-Plus Questions

1 / 15

1. Which of the following is the correct definition of sorting?

2 / 15

2. When will we use the function overloading?

3 / 15

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

#include
using namespace std;
 
class Test
{
  protected:
    int x;
  public:
    Test (int i):x(i) { }
    void fun() const  { cout << "fun() const " << endl; }
    void fun()        {  cout << "fun() " << endl;     }
};
 
int main()
{
    Test t1 (10);
    const Test t2 (20);
    t1.fun();
    t2.fun();
    return 0;
}

4 / 15

4. What is the difference between delete and delete[] in C++?

5 / 15

5. How can one implement the run-time Polymorphism in the C++ programming language?

6 / 15

6. Under which pillar of OOPS does base class and derived class relationship come?

7 / 15

7. dentify the correct definition of ‘*’ operator in pointer.

8 / 15

8. What did we call an array of the one-dimensional array?

9 / 15

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

#include 
using namespace std; 
template 
T max (T &a, T &b)
{
	cout << "Template Called ";
    return (a > b)? a : b;
}
 
template <>
int max  (int &a, int &b)
{
    cout << "Called ";
    return (a > b)? a : b;
}
 
int main ()
{
    int a = 10, b = 20;
    cout << max  (a, b);
}

10 / 15

10. Which of the following is not a type of inheritance?

11 / 15

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

        #include 

        using namespace std;

        int gcd (int a, int b)

        {

            int temp;

            while (b != 0) 

            {

                temp = a % b;

                a = b;

                b = temp;

            }

            return(a);

        }

        int main ()

        {

            int x = 15, y = 25;

            cout << gcd(x, y);

            return(0);

        }

12 / 15

12. Which of the following options correctly explains the concept of Polymorphism?

13 / 15

13. Which of the following can be considered as the object of an array?

14 / 15

14. Pick the incorrect statement about inline functions in C++?

15 / 15

15. Observer the given C++ program carefully and choose the correct output from the given options:

#include   
#include   
using namespace std;  
int main()  
{  
    cout<::value; // case A  
    cout<::value; // case B  
    cout<::value;  // case c  
    return 0;  
}  

Your score is

The average score is 32%

0%