C++

Practice questions for IT companies

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following data structures is not implemented by STL (Standard Template Library)?

  1. List
  2. Queue
  3. Stack
  4. Pointer
Question 2 Multiple Choice (Single Answer)

What is the notation of scope resolution operator?

  1. :
  2. *
  3. ::
  4. None of the above
Question 3 Multiple Choice (Single Answer)

Which of the following is involved in implementation of the concept of generic programming?

  1. Virtual functions
  2. Strings
  3. Templates
  4. Operator overloading
Question 4 Multiple Choice (Single Answer)

The member function can be defined outside class using

  1. size of operator
  2. scope resolution operator
  3. subscript operator
  4. none of the above
Question 5 Multiple Choice (Single Answer)

Which of the following is not an unary operator?

  1. *
  2. ++
  3. --
  4. +
Question 6 Multiple Choice (Single Answer)

POD is used to describe

  1. C++ classes
  2. C classes
  3. C++ structures
  4. C structures
Question 7 Multiple Choice (Single Answer)

What is the name of the term given to derived data type in which all data elements share the same location in memory?

  1. Pointers
  2. Structures
  3. Classes
  4. Unions
Question 8 Multiple Choice (Single Answer)

What is the name of the non-member function that can access all the private and protected members of a class?

  1. Virtual functions
  2. Static functions
  3. Friend functions
  4. Constructors
Question 9 Multiple Choice (Single Answer)

In C++, what are the names given to the functions which are not actually called rather their codes are substitued every time they are invoked?

  1. Inline functions
  2. Constructors
  3. Destructors
  4. None of the above
Question 10 Multiple Choice (Single Answer)

When we are making all data members of class private, which property of OOP are we using?

  1. Inheritance
  2. Polymorphism
  3. Encapsulation
  4. None of the above
Question 11 Multiple Choice (Single Answer)

What is the size of a far pointer?

  1. 1 byte
  2. 2 bytes
  3. 3 bytes
  4. 4 bytes
Question 12 Multiple Choice (Single Answer)

What is the output of the following code snippet?

#include <iostream>
using namespace std;
int main ()
{
int numbers[5];
int * p; p = numbers; *p = 10; p++; *p = 20;
p = &numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p+4) = 50;
for (int n=0; n<5; n++) cout << numbers[n] << , ;
return 0;
}

  1. 10, 20, 30
  2. 10, 20, 30, 40
  3. 10, 20, 30, 40, 50
  4. None of the above
Question 13 Multiple Choice (Single Answer)

Which of the following statements about abstract class is false?

  1. It must contain atleast one pure virtual function.
  2. Pointers to abstract class can be created.
  3. References to abstract classes can be created.
  4. Objects of abstract classes can be created.
Question 14 Multiple Choice (Single Answer)

Which of the following is not a built-in stream in C++?

  1. cin
  2. cout
  3. cerr
  4. none of the above
Question 15 Multiple Choice (Single Answer)

Which of the following is not a type of iterator?

  1. Random access
  2. Bi-directional
  3. Linear
  4. Output
Question 16 Multiple Choice (Single Answer)

Identify the problem with the following function declaration.

int sum(int a = 0,int b);

  1. Function declaration is correct.
  2. Parameter cannot be given default value in function declaration.
  3. All parameters that take default value, must appear to right of those that do not.
  4. Default argument of parameter cannot be zero.
Question 17 Multiple Choice (Single Answer)

Which language has exercised the greatest influence in the development of C++?

  1. ALGOL
  2. PASCAL
  3. C
  4. Simula 67
Question 18 Multiple Choice (Single Answer)

What is the output of the following C code?

#include<stdio.h>
int main()
{
short int i=0;
for(i;++i;i>=99)
printf(%d,i);
return 0;
}

  1. Infinite loop
  2. 1 to 32767 and then from -32768 to -1
  3. Compiler error
  4. Print from 1 to 99
Question 19 Multiple Choice (Single Answer)

What is the output of the following C++ code?

#include <iostream>
using namespace std;
int main()
{
cout.setf(ios::hex,ios::basefield);
cout<<100;
return 0;
}

  1. 100
  2. 144
  3. 64
  4. 40
Question 20 Multiple Choice (Single Answer)

Which of the following cast operators is used to override volatile attribute of variable?

  1. dynamic_cast
  2. static_cast
  3. const_cast
  4. reinterpret_cast
Question 21 Multiple Choice (Single Answer)

Which of the following keywords is not defined in C++?

  1. Ttry
  2. catch
  3. throw
  4. finally
Question 22 Multiple Choice (Single Answer)

What is the output of the following C code?

#include<stdio.h>
int main()
{
int i=0;
for(;i++;printf(%d,i));
printf(%d,i);
return 0;
}

  1. Infinite loop
  2. Compilation error
  3. Runtime error
  4. 1
Question 23 Multiple Choice (Single Answer)

What is the output of the following C++ code?

#include <stdio.h>
int main()
{
int a,b;
a = (b=2,b+3);
printf(%d,a);
return 0;
}

  1. 2
  2. Garbage value
  3. 5
  4. None of the above
Question 24 Multiple Choice (Single Answer)

Which of the following is not a reserved word in Standard C++?

  1. Inline
  2. Continue
  3. Return
  4. Overload
Question 25 Multiple Choice (Single Answer)

What is the output of the following C++ code?

#include <iostream>
using namespace std;
int main ()
{
int a;
for (a = 1; a <= 1; a++) cout << a++;
cout<< <<a;
return 0;
}

  1. 1 1
  2. 1 2
  3. 1 3
  4. 1 4