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

5/7

Page

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

What is static binding?

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[100];
int main()
{
    cout << x[99] << endl;
}

Select an option to see the answer and solution.

Which of the following is accessed by a member function of a class?

Select an option to see the answer and solution.

Which of the following type is provided by C++ but not C?

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
{
   private:
     int x;
   public:
     A(int _x)  {  x = _x; }
     int get()  { return x; }
};
class B
{
    static A a;
  public:
   static int get()
   {  return a.get(); }
}; 
int main(void)
{
    B b;
    cout << b.get();
    return 0;
}

Select an option to see the answer and solution.

What is the other name of compile-time polymorphism?

Select an option to see the answer and solution.

What is the size of a character type in C and C++?

Select an option to see the answer and solution.

Which of the following is the correct difference between cin and scanf()?

Select an option to see the answer and solution.

Which of the following is not a type of inheritance?

Select an option to see the answer and solution.

Which of the following is used for comments in C++?

Select an option to see the answer and solution.

Which of the following operator(s) can be used with pointers?
i. – only
ii. +, *
iii. +, –
iv. +, -, *
v. /
vi. + only

Select an option to see the answer and solution.

Which of the following is correct about this pointer in C++?

Select an option to see the answer and solution.

Which of the following syntax for declaring a variable of struct STRUCT can be used in both C and C++?

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 func()
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}

Select an option to see the answer and solution.

Which of the following is correct?

Select an option to see the answer and solution.

Which of the following is correct in C++?

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 Point
{
    int x, y;
  public:
   Point(int i = 0, int j =0)
   { x = i; y = j;  }
   int getX() const { return x; }
   int getY() {return y;}
};
 
int main()
{
    const Point t;
    cout << t.getX() << " ";
    cout << t.gety();
    return 0;
}

Select an option to see the answer and solution.

Which of the following escape sequence represents tab?

Select an option to see the answer and solution.

What is the other name of run-time polymorphism?

Select an option to see the answer and solution.

Which function is used to write a single character to console in C++?

Select an option to see the answer and solution.