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.
Questions
By default, which value is assigned to enumerated data type?
- 0
- 1
- -1
- None of the above
The program which we write in the edit window is known as ______.
- object file
- source file
- executable file
- none of these
In inheritance, when a protected member is inherited in public mode, it becomes ______ in the derived class.
- public
- private
- protected
- none of these
What is the output of the following program?
void main()
{
int z=-1;
cout<<z+5<< , <<z+3<< , <<z;
}
- - 5, - 2, - 2
- - 5, - 7, - 1
- 15, 18, 18
- - 15, - 18, - 18
Member functions can be defined
- outside the class definition
- inside the class definition
- both inside & outside the class definition
- none of the above
How many types of inheritance are there?
- 4
- 5
- 3
- 6
What type of error is encountered when the following program is executed?
#include<iostream.h>
void mail()
{
cout<< have a nice day ;
}
- Runtime error
- Compiler error
- Linker error
- Syntax error
What is the output of the following program?
void main();
{
int a=5,b=5;
cout<<a++;
cout<< -> ;
cout<<++a;
cout<< -> ;
cout<<b++;
}
- 5->7->6
- 6->7->5
- 5->7->5
- None of the above
The arrow operator accesses structure member via a pointer to object
- True
- False
What is the use of linker?
- Linker combines the object files into a single executable program.
- Linker converts the source file into object file.
- Linker converts the source file into executable file.
- None of the above
Which one of the following is a scope resolution operator?
- ->
- :
- &&
- ::
The function 'fputs' is declared in which header file?
- stdlib.h
- process.h
- stdio.h
- dos.h
The function 'isascii' is declared in which header file?
- dos.h
- stdlib.h
- alloc.h
- ctype.h
Is the following definition valid?
int array1={34,69};
- Yes
- No
Give output of the following
int i=1,j=1;
j++;
if (i==11)
cout<<' its eleven' ;
else
cout<<' its not eleven ';
- its eleven
- its not eleven
- Neither 1 or 2
- Data insufficient
How many levels of accessibility are offered by classes?
- 2
- 3
- 4
- None of the above
Virtual functions enable the possibility for a function to be polymorphic when it is overridden in one or more inherited classes.
- True
- False
Element 'myarray[4]' is which element of the array?
- Fourth
- Fifth
- Third
- None of the above
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;
}
- -330,150
- 330, -150
- -150, -330
- 6, 30
Which of the following is true about the static member variable?
- It is initialized to 0 when the first object is created.
- It is visible outside the class also.
- Every time an object is created, it is initialized to 1.
- None of the above
Select wildcard characters from the following?
- + , *
- ? , .
- * , #
- ? , *
Which one of the following can't be used as variable name?
- virtual
- assignment
- pointer
- object
Which one of the following is not a de-referencing operator?
- .*
- *
- ::*
- ::
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 ;
}
- applegrapesinvalid choice
- applegrapesinvalid choicebanana
- apple
- none of these
The operator << is called the ______________.
- extraction operator
- insertion operator
- get from operator
- put to operator
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;
}
- now = 5, next = 5
- now = 40, next = 5
- now = 10, next =10
- now = 40, next = 10
Which one of the following operators can't be overloaded?
- ::
- +
- +=
- []
Which one of the following statements is incorrect about friend functions?
- Declaration of a friend function in private or public section makes a difference to its meaning.
- It lies outside the scope of a class to which it is a friend.
- Unlike member functions, it can't access member names directly.
- It can be invoked without the help of any object.
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;
}
}
- A
- B
- C
- None of these
Justify: cout<<++x; cout<< , ;
cout<<++y;
cout<< , ;
cout<<- x;
cout<< , ;
cout<<y++;
}
- 5, 1, 4, 11
- 5, 1, 4, 1
- 5, 1, 3, 11
- 5, 1, 4, 1