C++ Based Questions

C++ Based Questions Questions for BCA, MCA Entrance and Placement Papers Preparation and Practice

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

How many arguments do destructors take?

  1. Two
  2. One
  3. Infinite
  4. None
Question 2 Multiple Choice (Single Answer)

A pure virtual function is a function that___________

  1. has no body
  2. returns nothing
  3. is used in a base class
  4. takes no arguments
Question 3 Multiple Choice (Single Answer)

When we pass arguments by reference, the formal arguments in the called function become aliases to the actual arguments in the calling function.

  1. True
  2. False
Question 4 Multiple Choice (Single Answer)

The last character in a string must be_________

  1. 0 (zero)
  2. - (null)
  3. empty
  4. none of the above
Question 5 Multiple Choice (Single Answer)

A constructor that accepts no parameters is called the ___________

  1. dynamic constructor
  2. parameterized constructor
  3. default constructor
  4. none of the above
Question 6 Multiple Choice (Single Answer)

A _______________ function can access a class private data, even though it is not a member function of the class.

  1. friend
  2. static
  3. virtual
  4. abstract
Question 7 Multiple Choice (Single Answer)

What is the result of the following statement?
cout<<sizeof(float);

  1. 4.000000
  2. 2
  3. 4
  4. 8
Question 8 Multiple Choice (Single Answer)

Which one of the following is a bitwise operator?

  1. !
  2. ~
  3. ==
  4. !=
Question 9 Multiple Choice (Single Answer)

Which one of the following is a valid method for accessing the 3rd element of the array cust?

  1. cust.3
  2. cust[3]
  3. cust[2]
  4. cust(2)
Question 10 Multiple Choice (Single Answer)

A function template definition begins with the keyword___________

  1. template
  2. class
  3. namespace
  4. class template
Question 11 Multiple Choice (Single Answer)

A C++ array can store values of different data types.

  1. True
  2. False
Question 12 Multiple Choice (Single Answer)

A pointer is a variable for storing

  1. integer values
  2. address of another variable
  3. its own address
  4. none of the above
Question 13 Multiple Choice (Single Answer)

What is the output of the following code?
int a=0;
for(int I=1;I<=a;I++)
cout<<I;

  1. 0
  2. 1
  3. Nothing will get displayed
  4. Error
Question 14 Multiple Choice (Single Answer)

What is the output of the following program?
#include<iostream.h>
void x(int a,int &b)
{
a=a+b;
a=a-b;
b=b-a;
}
void main()
{
int a=4,b=10;
x(a,b);
cout<<a<<b;
}

  1. 4, 10
  2. 10, 4
  3. 4, 4
  4. 4, 6
Question 15 Multiple Choice (Single Answer)

A constructor's name is same as __________

  1. function name
  2. class name
  3. function name or class name
  4. none of the above
Question 16 Multiple Choice (Single Answer)

Which manipulator is used to specify the required field size for displaying an output value?

  1. setfill()
  2. setprecision()
  3. setw()
  4. setiosflags()
Question 17 Multiple Choice (Single Answer)

A datatype that allows different data types to be assigned to the same storage location is called_________.

  1. enum
  2. union
  3. array
  4. none of the above
Question 18 Multiple Choice (Single Answer)

If p and q are int type variables, what will be the result of the following expression?
p % q
Where p = - 16 and q = - 3

  1. 1
  2. -1
  3. 5
  4. -5
Question 19 Multiple Choice (Single Answer)

The following examples show that the class R id derived from classes P and Q. Which of them is/ are legal?

  1. class R : public P : public Q
  2. class R : public P, Q
  3. class R : public P, public Q
  4. class R :: public P : public Q
Question 20 Multiple Choice (Single Answer)

The wrapping up of data and functions into a single unit is called _____________

  1. inheritance
  2. abstraction
  3. polymorphism
  4. encapsulation
Question 21 Multiple Choice (Single Answer)

Can class objects be passed to a function?

  1. Yes
  2. No
Question 22 Multiple Choice (Single Answer)

What is the value of a & b after the following two statements are executed?
int a=10;
int b=a++ * ++a;

  1. 132
  2. 110
  3. 120
  4. None of the above
Question 23 Multiple Choice (Single Answer)

Which one of the following is overloading the function?
int sum(int x,int y) {}

  1. int sum(int x,int y,int z) {}
  2. float sum(int x,int y) {}
  3. int sum(int a,int b) {}
  4. all of the above
Question 24 Multiple Choice (Single Answer)

The default case is required in the switch selection structure.

  1. Yes
  2. No
Question 25 Multiple Choice (Single Answer)

Opening a file in ios::out mode also opens it in the __________ mode by default.

  1. ios::app
  2. ios::in
  3. ios::trunc
  4. ios::nocreate