0
Alien head

C++ Based Questions

Description: C++ Based Questions Questions for BCA, MCA Entrance and Placement Papers Preparation and Practice
Number of Questions: 25
Created by:
Tags: Computer BCA MCA Entrance Placement Papers IT Placement Papers Computer Basics
Attempted 0/25 Correct 0 Score 0

How many arguments do destructors take?

  1. Two

  2. One

  3. Infinite

  4. None


Correct Option: D

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


Correct Option: A

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


Correct Option: A

The last character in a string must be_________

  1. 0 (zero)

    • (null)
  2. empty

  3. none of the above


Correct Option: B

A constructor that accepts no parameters is called the ___________

  1. dynamic constructor

  2. parameterized constructor

  3. default constructor

  4. none of the above


Correct Option: C

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


Correct Option: A

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

  1. 4.000000

  2. 2

  3. 4

  4. 8


Correct Option: C

Which one of the following is a bitwise operator?

  1. !

  2. ~

  3. ==

  4. !=


Correct Option: B

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)


Correct Option: C

A function template definition begins with the keyword___________

  1. template

  2. class

  3. namespace

  4. class template


Correct Option: A

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

  1. True

  2. False


Correct Option: B

A pointer is a variable for storing

  1. integer values

  2. address of another variable

  3. its own address

  4. none of the above


Correct Option: B

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


Correct Option: C

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


Correct Option: D

A constructor's name is same as __________

  1. function name

  2. class name

  3. function name or class name

  4. none of the above


Correct Option: B

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

  1. setfill()

  2. setprecision()

  3. setw()

  4. setiosflags()


Correct Option: C

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


Correct Option: B

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


Correct Option: B

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


Correct Option: C

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

  1. inheritance

  2. abstraction

  3. polymorphism

  4. encapsulation


Correct Option: D

Can class objects be passed to a function?

  1. Yes

  2. No


Correct Option: A

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


Correct Option: C

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


Correct Option: A

The default case is required in the switch selection structure.

  1. Yes

  2. No


Correct Option: B

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


Correct Option: C
+ View questions