Almost all MCQs of Computer

Object Oriented Programming(OOP) Solved MCQs


 What will be the output of following program?
#include<iostream.h>
void main()
{
float x;
x=(float)9/2;
cout<<x;
}


4.5
4.0
4
5
      _____________________________________________________________________________________
The term __________ means the ability to take many forms.

Inheritance
Polymorphism
Member function
Encapsulation
      _____________________________________________________________________________________
Runtime polymorphism is achieved by

Friend function
Virtual function
Operator overloading
Function overloading
      _____________________________________________________________________________________
Access to private data

Restricted to methods of the same class
Restricted to methods of other classes
Available to methods of the same class and other classes
Not an issue because the program will not compile
      _____________________________________________________________________________________
Additional information sent when an exception is thrown may be placed in

The throw keyword
The function that caused the error
The catch block
An object of the exception class
      _____________________________________________________________________________________
A static data member is given a value

Within the class definition
Outside the class definition
When the program is exeuted
Never
      _____________________________________________________________________________________
What will be the result of the expression 13 & 25?

38
25
9
12
      _____________________________________________________________________________________
In a class specifier ,data or function designated private are accessible

To any function in the program
Only if you the password
To member functions of that class
Only to public members of the class
      _____________________________________________________________________________________
Which of the statements are true ?
I. Function overloading is done at compile time.
II. Protected members are accessible to the member of derived class.
III. A derived class inherits constructors and destructors.
IV. A friend function can be called like a normal function.
V. Nested class is a derived class.


I, II, III
II, III, V
III, IV, V
I, II, IV
      _____________________________________________________________________________________
At which point of time a variable comes into existence in memory is determined by its

Scope
Storage class
Data type
All of the above
      _____________________________________________________________________________________
When the compiler cannot differentiate between two overloaded constructors, they are called

Overloaded
Destructed
Ambiguous
Dubious
      _____________________________________________________________________________________
The actual source code for implementing a template function is created when

The declaration of function appears.
The function is invoked.
The definition of the function appears.
None of the above.
      _____________________________________________________________________________________
Usually a pure virtual function

Has complete function body
Will never be called
Will be called only to delete an object
Is defined only in derived class
      _____________________________________________________________________________________
Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?

class d : public b1, public b2
class d : class b1, class b2
class d : public b1, b2
class d : b1, b2
      _____________________________________________________________________________________
The process of extracting the relevant attributes of an object is known as

Polymorphism
Inheritence
Abstraction
Data hiding
      _____________________________________________________________________________________
What features make C++ so powerful ?

Easy implementation
Reusing old code
Reusing old code
All of the above
      _____________________________________________________________________________________
Which of the following operator can be overloaded through friend function?

->
=
( )
*
      _____________________________________________________________________________________
The keyword friend does not appear in

The class allowing access to another class
The class desiring access to another class
The private section of a class
The public section of a class
      _____________________________________________________________________________________
Exception handling is targeted at

Run-time error
Compile time error
Logical error
All of the above
      _____________________________________________________________________________________
Function templates can accept

Any type of parameters
Only one parameter
Only parameters of the basic type
Only parameters of the derived type
      _____________________________________________________________________________________
If the variable count exceeds 100, a single statement that prints “Too many” is

if (count<100) cout << “Too many”;
if (count>100) cout >> “Too many”;
if (count>100) cout << “Too many”;
None of these.
      _____________________________________________________________________________________
The mechanism that binds code and data together and keeps them secure from outside world is known as

Abstraction
Inheritance
Encapsulation
Polymorphism
      _____________________________________________________________________________________
The operator << when overloaded in a class

must be a member function
must be a non member function
can be both (A) & (B) above
cannot be overloaded
      _____________________________________________________________________________________
To access the public function fbase() in the base class, a statement in a derived class function fder() uses the statement.fbase();

fbase();
fder();
base::fbase();
der::fder();
      _____________________________________________________________________________________
In which case is it mandatory to provide a destructor in a class?

Almost in every class
Class for which two or more than two objects will be created
Class for which copy constructor is defined
Class whose objects will be created dynamically
      _____________________________________________________________________________________
_________ members of a base class are never accessible to a derived class.

Public
Private
Protected
A,B and C
      _____________________________________________________________________________________
What is the error in the following code?
class t
{
virtual void print();
}


No error
Function print() should be declared as static.
Function print() should be defined.
Class t should contain data members.
      _____________________________________________________________________________________
It is possible to declare as a friend

A member function
A global function
A class
All of the above
      _____________________________________________________________________________________
A struct is the same as a class except that

There are no member functions
All members are public
Cannot be used in inheritance hierarchy
It does have a this pointer
      _____________________________________________________________________________________
C++ was originally developed by

Clocksin and Melish
Donald E.Knuth
Sir Richard Hadlee
Bjarne Stroustrup
      _____________________________________________________________________________________
What is the output of the following code
char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++)
cout << symbol [index];


a b c
“abc”
abc
‘abc’
      _____________________________________________________________________________________
If we create a file by ‘ifstream’, then the default mode of the file is _________

ios :: out
ios :: in
ios :: app
ios :: binary
      _____________________________________________________________________________________
The following can be declared as friend in a class

An object
A class
A public data member
A private data member
      _____________________________________________________________________________________
The polymorphism can be characterized by the phrase

One interface,multiple methods
Multiple interfaces,one method
One interface,one method
None of the above
      _____________________________________________________________________________________
A virtual class is the same as

An abstract class
A class with a virtual function
A base class
None of the above
      _____________________________________________________________________________________
Member functions, when defined within the class specification

Are always inline
Are not inline
Are inline by default, unless they are too big or too complicated
Are not inline by default.
      _____________________________________________________________________________________
Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = New Derived; in what sequence will the constructor be called ?

Derived class constructor followed by Base class constructor.
Base class constructor followed by derived class constructor.
Base class constructor will not be called.
Base class constructor will not be called.
      _____________________________________________________________________________________
The operator that cannot be overloaded is

++
: :
~
( )
      _____________________________________________________________________________________
Which of the following declarations are illegal?

void *ptr;
char *str = “hello”;
char str = “hello”;
const *int p1;
      _____________________________________________________________________________________
Identify the operator that is NOT used with pointers

->
&
*
>>
      _____________________________________________________________________________________
Which of the following statements is NOT valid about operator overloading?

Only existing operators can be overloaded
Overloaded operator must have at least one operand of its class type
The overloaded operators follow the syntax rules of the original operator
None of the above
      _____________________________________________________________________________________
Overloading a postfix increment operator by means of a member function takes

No argument
One argument
Two arguments
Three arguments
      _____________________________________________________________________________________
Which of the following will produce a value 10 if x = 9.7?

floor(x)
abs(x)
log(x)
ceil(x)
      _____________________________________________________________________________________
Which of the following is not the characteristic of constructor?

They should be declared in the public section.
They do not have return type.
They can not be inherited.
They can be virtual.
      _____________________________________________________________________________________
You may override the class access specifiers

Public members
Public and protected members
Any specific class members you choose
No class members
      _____________________________________________________________________________________
You separated a derived class name from its access specifier with

A colon
Two colons
Atleast one space
A semi colon
      _____________________________________________________________________________________
Consider the following statements:
int x = 22,y=15;
x = (x>y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?


22
37
7
5
      _____________________________________________________________________________________
A friend function to a class, C cannot access

Private data members and member functions
Public data members and member functions
Protected data members and member functions
The data members of the derived class of C
      _____________________________________________________________________________________
The members of a class by default are

Public
Protected
Private
Mandatory to specify
      _____________________________________________________________________________________
If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator)


00000111
10000010
10100000
11001000
      _____________________________________________________________________________________
[facebook]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget