Masters of Computer Application (C++)

C++ - An Objective Type Test for the Beginners Who Want to Start their Career in Object Oriented Programming Languages

30 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

How many types of storage classes are there in C++?

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

What is the output of the following program?
#include
void main()
{ enum birds{parrot,crow,pigeon,sparrow};
birds b=pigeon;
cout<
}

  1. pigeon
  2. 3
  3. 2
  4. none of the above
Question 3 Multiple Choice (Single Answer)

A function may return a reference or a pointer variable also.

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

Which one of the following error handling functions of ios class returns true, when an input or an output operation on file has failed?

  1. bad()
  2. good()
  3. eof()
  4. fail()
Question 5 Multiple Choice (Single Answer)
  • is also called the _________.
  1. address of operator
  2. reference operator
  3. value operator
  4. indirection operator
Question 6 Multiple Choice (Single Answer)

State, if the following comment is valid or not.
/* An apple /* a day keeps */ the doctor away */

  1. Valid
  2. Invalid
Question 7 Multiple Choice (Single Answer)

Is it important to define a virtual function in a base class even though it may not be used?

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

When a derived class is the base class of some other class, then this type of inheritance is known as ___________.

  1. hierarchical inheritance
  2. multiple inheritance
  3. multilevel inheritance
  4. hybrid inheritance
Question 9 Multiple Choice (Single Answer)

What is the output of the following program?#include
void main()
{
int x=7,y=6,z;
z=x-- -y;
cout<
}

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

Suppose p, q, r are integer variables with value 10, 20, 30 respectively. What will be the value of the following expression?
! ((q+r)>(r-10))

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

What is the output of the following expression?
int a=16,b= -8;
cout<

  1. 1
  2. 0
  3. - 1
  4. 0.0
Question 12 Multiple Choice (Single Answer)

What would be the output, if the input given to 'a' is Ram Krishan Verma?#include<iostream.h>
void main()
{
char a[10];
cin.getline(a,10);
cout<<a;
}

  1. Ram Krish
  2. Ram Krisha
  3. Ram Krishan
  4. Ram Krishan Verma
Question 13 Multiple Choice (Single Answer)

The following expression evaluates to the value _____.
0 + 1 * 3 - 1 * 5

  1. 10
  2. -10
  3. -2
  4. 2
Question 14 Multiple Choice (Single Answer)

An object pointer can point to private members of a class.

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

Which one of the following file modes allows us to add data or to modify the existing data anywhere in the file?

  1. ios::app
  2. ios::ate
  3. ios::out
  4. ios::trunc
Question 16 Multiple Choice (Single Answer)

What will be the output of the following program? void main()
{
int z[]={5,6,7,8,9,10};
int *p;
p=z;
cout<<*p+1;
}

  1. Base address of z
  2. 5
  3. 6
  4. Unknown value
Question 17 Multiple Choice (Single Answer)

What is the output of the following expression?
int a=16,b= -8;
cout<

  1. 1
  2. 0
  3. -1
  4. 0.0
Question 18 Multiple Choice (Single Answer)

How many types of storage classes are there in C++?

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

External variable is automatically initialized to ___________.

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

How many times will the following statement be executed?void main()
{
int a;
a=100;
while(a>=100)
{
cout<< hello ;
--a;
}
}

  1. Never
  2. Once
  3. 100
  4. 99
Question 21 Multiple Choice (Single Answer)

Which function in a stream sets the current get position?

  1. seekg()
  2. seekp()
  3. get()
  4. tellg()
Question 22 Multiple Choice (Single Answer)

What is the output of the following program?
#include<iostream.h>
void main()
{
enum birds{parrot,crow,pigeon,sparrow};
birds b=pigeon;
cout<<b;
}

  1. pigeon
  2. 3
  3. 2
  4. none of the above
Question 23 Multiple Choice (Single Answer)

What will be the output of the following program?

void main()

{
int p,q,r;
p=10;
q=20;
r=30;
if ((p>10)||(q<30))
if(r>p)
cout<<”Wintern”;
else if((p<q)&&(r<20))
cout<<”Summern”;
cout<<”Autumn”;}
  1. Winter Autumn
  2. Autumn
  3. Summer Autumn
  4. Winter
Question 24 Multiple Choice (Single Answer)

What is the output of the following program?
void main()
{
int z[]={5,6,7,8,9,10};
int *p;
p=z;
cout<<*p+1;
}

  1. Base address of z
  2. 5
  3. 6
  4. None of the above
Question 25 Multiple Choice (Single Answer)

What is the output of the following program? void main()
{
int m=10;
int *p=&m;
(*p)++;
cout<<(*p)++;
}

  1. 12
  2. 11
  3. 10
  4. Address of m
Question 26 Multiple Choice (Single Answer)

What will be the output of the following program?#include<iostream.h>
class sun
{
public:
void result()
{
cout<< class sun ;
}
};
class moon
{
public:
void result()
{
cout<< class moon ;
}
};
class stars:public sun,public moon
{
public:
void show()
{
cout<< class stars ;
}
};
void main()
{
stars s;
s.result();
}

  1. class stars
  2. class moon
  3. class sun
  4. none of the above
Question 27 Multiple Choice (Single Answer)

What will be the output of the following program?
#include<iostream.h>
class sun
{
public:
void result()
{
cout<< class sun ;
}
};
class moon
{
public:
void result()
{
cout<< class moon ;
}
};
class stars:public sun,public moon
{
public:
void show()
{
cout<< class stars ;
}
};
void main()
{
stars s;
s.result();
}

  1. class stars
  2. class moon
  3. class sun
  4. none of the above
Question 28 Multiple Choice (Single Answer)

Which one of the following languages is not an object oriented programming language?

  1. Ada
  2. Smalltalk
  3. Java
  4. Object Pascal
Question 29 Multiple Choice (Single Answer)

By default, the members of a structure are __________.

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

External variable is automatically initialized to ___.

  1. 0
  2. 1
  3. -1
  4. none of the above