Masters of Computer Applications (C++)

Comprehensive C++ programming practice questions for MCA Entrance Exam preparation. Covers inheritance, operators, classes, pointers, functions, arrays, and other core C++ language concepts.

30 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

By default, which value is assigned to enumerated data type?

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

The program which we write in the edit window is known as ______.

  1. object file
  2. source file
  3. executable file
  4. none of these
Question 3 Multiple Choice (Single Answer)

In inheritance, when a protected member is inherited in public mode, it becomes ______ in the derived class.

  1. public
  2. private
  3. protected
  4. none of these
Question 4 Multiple Choice (Single Answer)

What is the output of the following program?
void main()
{
int z=-1;
cout<<z+5<< , <<z+3<< , <<z;
}

  1. - 5, - 2, - 2
  2. - 5, - 7, - 1
  3. 15, 18, 18
  4. - 15, - 18, - 18
Question 5 Multiple Choice (Single Answer)

Member functions can be defined

  1. outside the class definition
  2. inside the class definition
  3. both inside &amp; outside the class definition
  4. none of the above
Question 6 Multiple Choice (Single Answer)

How many types of inheritance are there?

  1. 4
  2. 5
  3. 3
  4. 6
Question 7 Multiple Choice (Single Answer)

What type of error is encountered when the following program is executed?

#include<iostream.h>
void mail()
{
cout<< have a nice day ;
}

  1. Runtime error
  2. Compiler error
  3. Linker error
  4. Syntax error
Question 8 Multiple Choice (Single Answer)

What is the output of the following program?
void main();
{
int a=5,b=5;
cout<<a++;
cout<< -> ;
cout<<++a;
cout<< -> ;
cout<<b++;
}

  1. 5-&gt;7-&gt;6
  2. 6-&gt;7-&gt;5
  3. 5-&gt;7-&gt;5
  4. None of the above
Question 9 Multiple Choice (Single Answer)

The arrow operator accesses structure member via a pointer to object

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

What is the use of linker?

  1. Linker combines the object files into a single executable program.
  2. Linker converts the source file into object file.
  3. Linker converts the source file into executable file.
  4. None of the above
Question 11 Multiple Choice (Single Answer)

Which one of the following is a scope resolution operator?

  1. -&gt;
  2. :
  3. &amp;&amp;
  4. ::
Question 12 Multiple Choice (Single Answer)

The function 'fputs' is declared in which header file?

  1. stdlib.h
  2. process.h
  3. stdio.h
  4. dos.h
Question 13 Multiple Choice (Single Answer)

The function 'isascii' is declared in which header file?

  1. dos.h
  2. stdlib.h
  3. alloc.h
  4. ctype.h
Question 14 Multiple Choice (Single Answer)

Is the following definition valid?
int array1={34,69};

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

Give output of the following
int i=1,j=1;
j++;
if (i==11)
cout<<' its eleven' ;
else
cout<<' its not eleven ';

  1. its eleven
  2. its not eleven
  3. Neither 1 or 2
  4. Data insufficient
Question 16 Multiple Choice (Single Answer)

How many levels of accessibility are offered by classes?

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

Virtual functions enable the possibility for a function to be polymorphic when it is overridden in one or more inherited classes.

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

Element 'myarray[4]' is which element of the array?

  1. Fourth
  2. Fifth
  3. Third
  4. None of the above
Question 19 Multiple Choice (Single Answer)

What is the output of the following program?
#include<iostream.h>
void fun(int &a,int &b)
{
a=a*b;
b=b-a;
a=a-b;
}
void main()
{
int a=6,b=30;
fun(a,b);
cout<<a<< , <<b;
}

  1. -330,150
  2. 330, -150
  3. -150, -330
  4. 6, 30
Question 20 Multiple Choice (Single Answer)

Which of the following is true about the static member variable?

  1. It is initialized to 0 when the first object is created.
  2. It is visible outside the class also.
  3. Every time an object is created, it is initialized to 1.
  4. None of the above
Question 21 Multiple Choice (Single Answer)

Select wildcard characters from the following?

  1. + , *
  2. ? , .
  3. * , #
  4. ? , *
Question 22 Multiple Choice (Single Answer)

Which one of the following can't be used as variable name?

  1. virtual
  2. assignment
  3. pointer
  4. object
Question 23 Multiple Choice (Single Answer)

Which one of the following is not a de-referencing operator?

  1. .*
  2. *
  3. ::*
  4. ::
Question 24 Multiple Choice (Single Answer)

Give output of the following, if the input given is 'a'.
cin>>choice;
switch(choice)
{
case ' b' :cout<< banana ;
break;
case ' a' :cout<< apple ;
case ' g' :cout<< grapes ;
default :cout<< invalid choice ;
}

  1. applegrapesinvalid choice
  2. applegrapesinvalid choicebanana
  3. apple
  4. none of these
Question 25 Multiple Choice (Single Answer)

The operator << is called the ______________.

  1. extraction operator
  2. insertion operator
  3. get from operator
  4. put to operator
Question 26 Multiple Choice (Single Answer)

What is the output of the following program?
#include<iostream.h>
static int j=10;
void value()
{
static int j=40;
cout<< now= <<j<< , ;
}
void value()
{
static int j=5;
value();
cout<< next= <<j;
}

  1. now = 5, next = 5
  2. now = 40, next = 5
  3. now = 10, next =10
  4. now = 40, next = 10
Question 27 Multiple Choice (Single Answer)

Which one of the following operators can't be overloaded?

  1. ::
  2. +
  3. +=
  4. []
Question 28 Multiple Choice (Single Answer)

Which one of the following statements is incorrect about friend functions?

  1. Declaration of a friend function in private or public section makes a difference to its meaning.
  2. It lies outside the scope of a class to which it is a friend.
  3. Unlike member functions, it can't access member names directly.
  4. It can be invoked without the help of any object.
Question 29 Multiple Choice (Single Answer)

Which one of the following is a default constructor?
A. class star
{
private:
int a;
public:
star(int a)
{
a=0;
}
}

B. class star
{
private:
int a;
public:
star()
{
a=0;
}
}
C. class star
{
private:
int a,b;
public:
star(int a,int b)
{
a=0;
b=0;
}
}

  1. A
  2. B
  3. C
  4. None of these
Question 30 Multiple Choice (Single Answer)

Justify: cout<<++x; cout<< , ;
cout<<++y;
cout<< , ;
cout<<- x;
cout<< , ;
cout<<y++;
}

  1. 5, 1, 4, 11
  2. 5, 1, 4, 1
  3. 5, 1, 3, 11
  4. 5, 1, 4, 1