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

6/7

Page

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

Which of the following is the correct syntax of including a user defined header files in C++?

Select an option to see the answer and solution.

Which of the following operator has left to right associativity?

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
{
   private:
     static int count;
   public:
     Test& fun(); 
};
int Test::count = 0;
Test& Test::fun()
{
    Test::count++;
    cout << Test::count << " ";
    return *this;
}
int main()
{
    Test t;
    t.fun().fun().fun().fun();
    return 0;
}

Select an option to see the answer and solution.

Which function is used to read a single character from the console in C++?

Select an option to see the answer and solution.

Which of the following is a correct identifier in C++?

Select an option to see the answer and solution.

What happens if the following program is compiled in both C and C++?
#include<stdio.h>
struct STRUCT
{
  int static a;
};
int main()
{
  struct STRUCT s;
  return 0;
}

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 Player
{
  private:
    int id;
    static int next_id;
  public:
    int getID() { return id; }
    Player()  {  id = next_id++; }
};
int Player::next_id = 1;
int main()
{
  Player p1;
  Player p2;
  Player p3;
  cout << p1.getID() << " ";
  cout << p2.getID() << " ";
  cout << p3.getID();
  return 0;
}

Select an option to see the answer and solution.

Which of the following statement is correct?

Select an option to see the answer and solution.

A language which has the capability to generate new data types are called . . . . . . . .

Select an option to see the answer and solution.

Which of the following is not a fundamental type is not present in C but present in C++?

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 called insertion/put to operator?

Select an option to see the answer and solution.

Which of the following feature is not provided by C?

Select an option to see the answer and solution.

Const qualifier can be applied to which of the following?
i. Functions inside a class
ii. Arguments of a function
iii. Static data members
iv. Reference variables

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
class Test
{
   public:
     void fun();
};
static void Test::fun()   
{
    std::cout<<"fun() is static";
}
int main()
{
    Test::fun();   
    return 0;
}

Select an option to see the answer and solution.

How many types of polymorphism are there?

Select an option to see the answer and solution.

What are the escape sequences?

Select an option to see the answer and solution.

Which of the following operator is used with this pointer to access members of a class?

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(void)
{
	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.