Vidyalelo
C++ Programming · all questions

Introduction to C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

138

Questions

4/7

Page

Pick an option on a question to see the right answer and solution.

Which of the following is correct?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class A
{
  ~A(){
    cout<<"Destructor called\n";
  }
};
int main()
{
    A a;
    return 0;
}

Select an option to see the answer and solution.

Why this pointer is used?

Select an option to see the answer and solution.

Which of the following is correct about static variables?

Select an option to see the answer and solution.

Which of the following syntax can be used to use a member of a namespace without including that namespace?

Select an option to see the answer and solution.

Who created C++?

Select an option to see the answer and solution.

Which of the following is correct about static polymorphism?

Select an option to see the answer and solution.

Which of the following is the scope resolution operator?

Select an option to see the answer and solution.

What happens if the following program is executed in C and C++?
#include <stdio.h> 
void main() 
{ 
	printf("Hello World"); 
}

Select an option to see the answer and solution.

Which of the following is an entry-controlled loop?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
int const s=9;
int main()
{
    std::cout << s;
    return 0;
}

Select an option to see the answer and solution.

Which concept is used to implement late binding?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
 
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}

Select an option to see the answer and solution.

Which of the following cannot be used with the virtual keyword?

Select an option to see the answer and solution.

What happens if the following program is executed in C and C++?
#include <stdio.h> 
int main(void) 
{ 
	int new = 5;
	printf("%d", new); 
}

Select an option to see the answer and solution.

Which of the following is an exit-controlled loop?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Test
{
    static int x;
  public:
    Test() { x++; }
    static int getX() {return x;}
};
int Test::x = 0;
int main()
{
    cout << Test::getX() << " ";
    Test t[5];
    cout << Test::getX();
}

Select an option to see the answer and solution.

What happens if the following program is executed in C and C++?
#include<stdio.h> 
int main() 
{ 
   foo();
}  
int foo() 
{ 
   printf("Hello"); 
   return 0;  
}

Select an option to see the answer and solution.

Which of the following is C++ equivalent for scanf()?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int x = 1;
int main()
{
    int x = 2;
    {
        int x = 3;
        cout << ::x << endl;
    }
    return 0;
}

Select an option to see the answer and solution.