Object Oriented Programming Solved MCQs - Part 2


It is possible to declare as a friend

A member function
A global function
A class
All of the above
      _____________________________________________________________________________________
What will be the result of the expression 13 & 25?

38
25
9
12
      _____________________________________________________________________________________
A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________

Call by name
Call by value
Call by reference
Call by value result
      _____________________________________________________________________________________
The members of a class, by default, are

Public
Protected
Private
Mandatory to specify
      _____________________________________________________________________________________
Which of the following is a string literal constant?

“Visual C++”
“137.45”
“A”
All of the above
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
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’
      _____________________________________________________________________________________
Which of the statements is true in a protected derivation of a derived class from a base class?

Private members of the base class become protected members of the derived class
Protected members of the base class become public members of the derived class
Public members of the base class become protected members of the derived class
Protected derivation does not affect private and protected members of the derived class
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
The concept of hierarchical classification is related to

Abstraction
Inheritance
Function overloading
None
      _____________________________________________________________________________________

Assume that we have constructor function for both Base and Derived classes. Now consider the declaration :

main ( )
Base *p = new Derived;
In what sequence, the constructor will be executed ?


Derived class constructor is followed by Base class constructor.
Base class constructor is followed by Derived class constructor.
Base class constructor is never called.
Derived class constructor is never called.
      _____________________________________________________________________________________
If you wanted to sort many large objects or structures, it would be most efficient to 

Place them in an array and sort the array.
Place pointers to them in an array and sort the array.
Place them in a linked list and sort the linked list.
Place references to them in an array and sort the array.
      _____________________________________________________________________________________
cfront

is the front end of a C compiler
is the per-process of a C compiler
is a tool that is translated a C++ code to its equivalent C code
None of 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
      _____________________________________________________________________________________
A static data member is given a value

Within the class definition
Outside the class definition
When the program is exeuted
Never
      _____________________________________________________________________________________
C++ was originally developed by

Clocksin and Melish
Donald E.Knuth
Sir Richard Hadlee
Bjarne Stroustrup
      _____________________________________________________________________________________
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.
      _____________________________________________________________________________________
If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access

Protected and public data only in C and B
Protected and public data only in C
Private data in A and B
Protected data in A and B
      _____________________________________________________________________________________
A friend function has access to all private and protected members of the class for which it is a friend 

Only private
Private and protected
Only protected
None of the above
      _____________________________________________________________________________________
Which of the following cannot be legitimately passed to a function 

A constant
A variable
A structure
A header file
      _____________________________________________________________________________________
Match the following :
(a) Garbage collection in     1. Java
(b) Nameless object             2. generic programming
(c) Template support            3. defines a class
(d) A forward reference       4. member function
(e) Derived class inherits
from base class 


1   5   4   2   3
1   5   2   3   4
5   1   2   3   4
5   4   3   1   2
      _____________________________________________________________________________________
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 class defined within another class is 

Nested class
Inheritance
Containership
Encapsulation
      _____________________________________________________________________________________
In multiple inheritance 

The base classes must have only default constructors
Cannot have virtual functions
Cannot have virtual classes
None of the above
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
In C++, dynamic memory allocation is accomplished with the operator ____

new
this
malloc( )
delete
      _____________________________________________________________________________________
Use of virtual functions implies

Overloading
Overriding
Static binding
Dynamic binding
      _____________________________________________________________________________________
Which of the following type casts will convert an Integer variable named amount to a Double type?

(double) amount
(int to double) amount
int to double(amount)
int (amount) to double
      _____________________________________________________________________________________
The members of a class by default are 

Public
Protected
Private
Mandatory to specify
      _____________________________________________________________________________________
 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
      _____________________________________________________________________________________
Which feature in OOP allows reusing code?

Polymorphism
Inheritance
Encapsulation
Data hiding
      _____________________________________________________________________________________
Exception handling is targeted at

Run-time error
Compile time error
Logical error
All 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, if any, are valid names for variables?

class
friend
void
None of the above is valid names for variables
      _____________________________________________________________________________________
What does C++ append to the end of a string literal constant?

a space
a number sign (#)
an asterisk (*)
a null character
      _____________________________________________________________________________________
A template class 

Is designed to be stored in different containers
Works with different data types
Generates objects which must be identical
Generates classes with different numbers of member functions
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
An array element is accessed using

a first-in-first-out approach
the dot operator
a member name
an index number
      _____________________________________________________________________________________
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.
      _____________________________________________________________________________________
An exception is caused by 

A hardware problem
A problem in the operating system
A syntax error
A run-time error
      _____________________________________________________________________________________
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();
      _____________________________________________________________________________________
RunTime Polymorphism is achieved by ______ 

Friend function
Virtual function
Operator overloading
Function overloading
      _____________________________________________________________________________________
Runtime polymorphism is achieved by

Friend function
Virtual function
Operator overloading
Function overloading
      _____________________________________________________________________________________
Pure virtual functions 

Have to be redefined in the inherited class
Cannot have public access specification
Are mandatory for a virtual class
None of the above
      _____________________________________________________________________________________
If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator)


00000111
10000010
10100000
11001000
      _____________________________________________________________________________________
Identify the operator that is NOT used with pointers

->
&
*
>>
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
A variable defined within a block is visible 

From the point of definition onward in the program
From the point of definition onward in the function
From the point of definition onward in the block
Throughout the function
      _____________________________________________________________________________________
The function whose prototype is void getData(Item *thing); receives

a pointer to a structure
a reference to a structure
a copy of a structure
nothing
      _____________________________________________________________________________________
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
      _____________________________________________________________________________________
Previous Post Next Post