Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

CS304 Quiz 2

Suppose derived class is inherited from base class. What happens when a derived class object
is created?

The constructor of base class is executed before the constructor of derived class.

Suppose str1, str2 and str3 are objects of class String. Choose appropriate declaration of
overloaded assignment operator for the following statement to work correctly.

str1 = str2 = str3;

String& operator =(const String &);

In C++, which of the following is defined as stream insertion operator?

<<

Choose correct declaration of overloaded inequality (!=) operator for class String as non-
member friend function.

None of the given options

Relationship in which child object gets destroyed if parent object is destroyed.

Composition

How the information hidden within an object can be accessed?

Through its interface

Which of the following defines default constructor for class "Student"?

Student() {//...

The sub-object’s life is not dependent on the life of master class in ___________.

Aggregation

Hiding the implementation details makes program:


Easy to understand

The functions defined inside the class are by default ________.

Inline

Which of the following statement is TRUE about static function of a class?

It is used to access static data members.

Deconstruct is a function which has the same name as that of class but starts with a—– sign

'this' pointer cannot be passed implicitly to __________ functions.

Static Member

Which of the following can be the behavior of an object “Usman”?

Eat

In Object Oriented programming, objects communicate with each other through ________

Messages

Constructor is used to______the objects of a class.

Initialize

Which of the following is NOT an access specifier in C++?

Hidden

The other name of subtyping is ________.

Extension

Suppose a class does not have any constructor. What will happen when an object of this class is
created?

Compiler will call implicit default constructor.


In case when we define the function outside the class then we must use the keyword _________
to make the function inline.

Inline

In constant member function the type of this pointer is:

Constant pointer to constant data

In ____________, base class can be replaced by the derived class.

Extension

We can get the address of a variable stored in a pointer using __________:

& symbol

A child inherits characteristics from its _________.

Parent

Which of the following function declaration is correct to overload the + operator as member function in
Complex class?

Complex operator +(const Complex & rhs);

Which of the following is not true about constant member function?

All of the given options

What is the general syntax of overloading Unary Operator as member function of the class?

TYPE & operator OP ();

_____ is creating objects of one class inside another class.

Composition

Which of the following is true about constructor?


All of the given option
Memory is allocated to non static members only, when
Object is created

A child inherit characteristics from its ?


parents

A post-fix unary operator is implemented in C++ member function with


1 dummy int arguments

Which of the following is the example of objects in school?


Books , pages

Suppose student is a class, which of the following constructor with one parameter for class student?
Student()

If you have three classes in a C++ program A, B, and C where class A inherits from class B, then class
______ contains all the characteristics of class ________.
A, C

In ____ base class can be replaced by the derived class.


Extension

The concept of derived class is involved in _____


inheritance

Suppose person is a class which of the following statement defines an object of class person?
Create person object

Which of the following is true about Accessor Functions?


They are also used to access private data of the object.
It can be used to set private data member of the class
It can be used to get private data member of the class
All of the given options.

The other name of subtyping is


Extension
Which of the following statement best describes the constructor
constructor is used to initialize the data member of a class.

Which of the following is true about inline function?


It is used by compilers to improve efficiency of the program

Which of the following is defined as stream extraction operator in c++?


>>

An object has ___ interface(s)


One or more than one

Which of the following is an advantage of encapsulation?


Better understanding

Which of the following represents the two-way association?


Employee works for the company

___ is the weakest link between object.


Simple association

Which of the following statement is NOT true about static variable of a class?

In composition ______ are called from composing objects to compound objects.


Constructor

In OOP we can achieve reusability though ______


Inheritance

Generalization is implemented through


Inheritance

Suppose str1, str2, and str3 are objects of class string. Choose appropriate declaration of overloaded
assignment operator for the following statement to work correctly.
String& operator=(const String &)

In C++ which of the following is defined as stream insertion operator.


<<
Abstraction hides the ___ details.
Relevant

Minimum classes required in a program for implementing multiple inheritance.


3

Composition is _______ and aggregation is ______ relationship.


Strong, weak

Minimum classes required for implementing multiple inheritance.


At least 3

We can access a private static variable through.


Static data member

The process of extracting common characteristics from two or more classes and combining them into a
generalized superclass is called ___
Generalization

Which of the following is true about polymorphism?


All of the given

Which of the following can be the behavior of an object “Usman”?


Eat

Composition is ____ relationship


Part whole

Which of the following is a strong relationship?


Composition

Which of the following defines default constructor for class student?


Student(){/…
}

This car is composed of wheels. What is the relationship between car and wheels?
Composition
In ____ base class can be replaced by the derived class.
Extension

___ defines the order of evaluation of an operator is an expression.


Operator precedence

In composition __ are called from composing objects to composed objects.


Destructor

How many objects of a given class may be constructed in an application?


As many as the application asks for

Relationship in which child object gets destroyed, If parent object is destroyed.


Composition

Which of the following is not true about constructor?


Constructor is a special function which can have different name than class name.

Suppose test is a class, void show() is its public member function. which of the following is correct call of
show() function using Test pointer ptr?
ptr->show()

Which of the following features of OOP is used to deal with only relevant details?
Abstraction

In C++ the subscript operator must be overloaded as a ___ of the class, with one parameter of ___ type.
Member function, int

Identify the abstract class from the given statement


“vehicle class is base class. Bus, Car and truck are derived classes”
Vehicle

How can we differentiate between constructor and destructors?


Destructor are preceded by a tilde(~) symbol and constructor are not preceded with any symbol.

If you do not initialize static variable of int type then it is automatically initialized with ____
0
Choose the correct statement
All of the given options

___ associates the objects of the exact two classes.


Binary association

Which of the following is the advantage of inheritance?


Reusability

Member function defined inside a class declaration are __ by default


Public

In Object Oriented programming objects communicate with each other through ____
Messages

____ associates the objects of the exact three classes.


Ternary Association

An objects has attributes, operations and _____


Unique identity

In C++ which of the following keywords works only with constructors?


Explicit

Which of the following allows to reuse characteristics of more than one parent class?
Multiple Inheritance

How many objects are involved in the Binary association?


2

Which of the following features of OOP is used to deal with only relevant details?
Abstraction

The overloaded ‘-‘ operator for complex class will be called with reference to ___ in the following
statement
Complex C3 = C1 – C2
Complex
Static data member is declared __
Inside the class

Class is blue print of ___


Object

Which of the following is true about inline functions?


All of the given options

How many objects can be created once a class is declared?


As many as needed

Suppose you have following C++ statements


int oldValue=10
intviewValue * ++ old/Value
What will be the value of old/Value and new/Value after executing above statement?
old/Value=11, new/Value=11

In ___ base class can’t always be replaced by the derived class.


Specialization

Which of the following will happen when a constant function tries to change the value of data members
of the class?
Complex time error will occur

_____ is set of functions of an objects exposed to other objects.


Interface

How many objects are involved in the Ternary association?


3

Mermaid is an example of
Multiple inheritance

Which of the following is the correct syntax of declaring static variable ‘count’ of type int?
static int count
Which of the following operators operate on one operand?
Unary Operators

Object Data includes ___


Both static and attributes of an objects

In case when we define the function outside the class then we must use the keyword ___ to make
function inline.
Inline

An abstract class is useful when


Select correct option:
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.
you want to defer the declaration of the class.

In resolution order compiler search firstly _______.


Select correct option:
Generic Template
Partial Specialization
Complete Specialization
Ordinary function

template<> class Vector{ void** p; //.... void*& operator[] ((int i); };


Select correct option:
This specialization can then be used as the common implimentation for all
Vectors of pointers.
This spcialization can then be used as the all type implimentation for one type
classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.
In private inheritance derived class pointer can be assigned to base class
pointer in,
Select correct option:
Main function
In derived class member and friend functions
In base class member and friend functions
None of the given options

Which statement will be true for concrete class?


it implements an virtual concept.
it can be instantiated
it cannot be instantiated
none of given

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

The Specialization pattern after the name says that this specialization is to be
used for every___.
Select correct option:
data types
meta types
virtual types
pointers type

c++ dynamic binding and polymorphism will be achieved when member


function will be __.
Select correct option:
private
public
virtual
inline

Consider the code below, class class1{ protected: void func1(); }; class class2
: public class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ protected: int i; }; class class2 :
protected class1 { }; Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ private: void func1(); }; class class2 :
private class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Target of a _____ function call is determined at run time.

Select correct option:


instance
virtual
operator
none of given

The Specialization pattern after the name says that this specialization is to be used for
every___.
Select correct option:
data types
meta types
virtual types
pointers type

c++ dynamic binding and polymorphism will be achieved when member function will
be __.
Select correct option:
private
public
virtual
inline

Consider the code below, class class1{ protected: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ protected: int i; }; class class2 : protected class1
{ }; Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ private: void func1(); }; class class2 : private
class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given

Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;


Select correct option:
These statements will compile successfully
Error in first statement
Error in second statement
None of given options

Consider the code below, class class1{ private: int i; }; class class2 : private class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

If there is a pointer, p, to objects of a base class, and it contains the address of an


object of a derived class, and both classes contain a virtual member function, ding(),
then the statement p->ding(); will cause the version of ding() in the ___ class to be
executed.
Select correct option:
base
derived
virtual
implemented
A class template may inherit from another class template.
Select correct option:
True
False

Derived class can inherit from public base class as well as private and protected base
classes
Select correct option:
True
False
Two functions with same names, parameters and return type can exist in,
Select correct option:
Function overloading
Function overriding
Operator overloading
None of these options

Consider the code below, class class1{ private: int i; }; class class2 : public class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Target of a _____ function call is determined at run time.


Select correct option:
instance
virtual
operator
none of given
A class template may inherit from another class template.
Select correct option:
True
False

A function call is resolved at run-time in_________


Select correct option:
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given

hello

A class hierarchy
Select correct option:
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.

Consider the code below, class class1{ public: int i; }; class class2 : public class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { };
Then c1 is,
Select correct option:
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2

A class can inherit from more then one class is called.


Select correct option:
Simple inheritance
Multiple inheritances
Single inheritance
Double inheritance
template<> class Vector{ void** p; //.... void*& operator[] ((int i); };
Select correct option:

This specialization can then be used as the common implimentation for all Vectors of
pointers.
This spcialization can then be used as the all type implimentation for one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.

Consider the code below, class class1{ public: int i; }; class class2 : protected class1 { };
Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Consider the code below, class class1{ private: void func1(); }; class class2 : public
class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Templates automatically create different versions of a function, depending on user


input.
Select correct option:
True
False

_________ Binding means that target function for a call is selected at run time
Select correct option:
Automatic
Dynamic
Static
Dramatic
When we create objects, then space is allocated to:

Member function

Access specifier

Data member
None of given

There is only one form of copy constructor.

True
False

Which of the following features of OOP is used to deal with only relevant details?

Abstraction

Information hiding
Object

____________ Binding means that targets function for a call is selected at compile time.
Static
Dynamic

Automatic

None of given

A Class hierarchy

Shows the same relationships as an organization chart

Describes “has a” relationships.


Describes “is a kind of” relationships.
Shows the same relationships as a family tree

In C++, we declare a function virtual by preceding the function header with keyword
“Inline”
True
False

It is illegal to make objects of one class members of another class.


True
False

In Resolution order compiler search firstly____________.

Generic Template

Partial Specification

Complete Specification
Ordinary function

Derived class can inherit from public base class as well as private and protected base
classes
True
False
Which line will produce error. Class phone: Private Transmit, private Receiver { } 1.int
main () 2. { 3.phone obj; 4.Tranmit*obj1 = &obj; 5.Received obj2 = &obj; 6.}

3rd line will produce error


4th line will produce error
3rd and 4th line will produce error.
5th line will produce error.

Methodologies to the development of reusable software relate to ____________.

Structure programming

Procedural programming
Generic programming
None of the given

A template argument is preceded by the keyword__________.

Vector
Class
Template

Type*

Friends are used exactly the same for template and non-template classes.

True
False
A function template must have a parameter
True
False

Child class can call constructor of its,


Direct base class
Indirect base class

Both direct and indirect base classes

None of these.

Which statement will be true for concrete class?

It implements an virtual concept.


It can be instantiated
It cannot be instantiated

None of given

A class D can be derived from a class C, which is derived froma class B, which is
derived from a class A
True
False

Adding a derived class to a base class requires fundamental changes to the base class.
True
False

A Class or class template can have member ___________ that are themselves
templates.

Variable
Function
Objects

None of given

Which will be the Primary task or tasks of generic programming?


Categorize the abstractions in a domain into concepts

Implement generic algorithms based on the concepts

Build concrete models of the concepts


All of given

The default inheritance mode is,


Public inheritance
Protected Inheritance

Private Inheritance

None of these options

If there is a pointer, p, to objects of a base class, and it contains the address of an


object of a derived class, and both classes contain a virtual member function, ding(),
then the statement p->ding(); will cause the version of ding() in the __________class to
be executed.

Base

Derived
Virtual
Implemented

A class template ____________

Facilitates reuse of class

Does not facilitate reuse of class

Sender of the message does not need to know the exact class of receiver in________.

Abstraction

Polymorphism
Inheritance

none of the given

CS304 Object Oriented Programming Solved MCQs


from Quiz 2 a

CS304 Object Oriented Programming 1. Select correct line of code for inheritance
relationship between “Gender” class and “Male” class. “Gender” is parent class
while “Male” is child class.
class Male: public Gender
class Gender: public Male
class Male:: public Gender
class Gender:: public Male

CS304 Object Oriented Programming 2. In______________, a pointer or reference


to an object is created inside a class.
Aggregation
Composition
Inheritance
Association

CS304 Object Oriented Programming 3.Select correct line of code for inheritance
relationship between “Person” class and “Supervisor” class. “Person” is parent
class while “Supervisor” is child class.
class Supervisor: public Person
class Person: public Supervisor
class Supervisor:: public Person
class Person:: public Supervisor

CS304 Object Oriented Programming 4.The direction specifies which object


contains the other object. In composition direction is must.
No
Yes

CS304 Object Oriented Programming 5. Select correct line of code for inheritance
relationship between “Keys” class and “SpecialKeys” class. “Person” is parent
class while “SpecialKeys” is child class.
class SpecialKeys: public Keys
class Keys: public SpecialKeys
class SpecialKeys:: public Keys
class Keys:: public SpecialKeys

CS304 Object Oriented Programming 6. “Keyboard” class is composed of “keys”


class. What will be the order of execution of constructor of “Keyboard” class and
“Keys” class?
First Detructor::Keys..
Second Destructor::Keyboard..
First Destructor:: Keyboard..
Second Destructor:: Keys..

CS304 Object Oriented Programming 7. Identify which of the following


overloaded operator function's declaration is appropriate for the given call?
Rational_number_1 + 2.325 Where Rational_number_1 is an object of user
defined class Rational_number.
Rational_number operator+( Rational_number & obj);
None of the given choices
Rational_number operator+(Rational_number &obj, double& num);
operator+(double& obj);

CS304 Object Oriented Programming 8. In _______________ a pointer or


reference to an object is created inside a class
Aggregation
Composition
Seperation
None of the given

CS304 Object Oriented Programming 9. Sub-Object can not be initialized using


the constructor
True
False

CS304 Object Oriented Programming 10. Let Suppose a class Student with
objects std1, std2, and std3. For the statement std3 = std1 - std2 to work
correctly, if the overloaded - operator must
take two arguments.
None of the given choices
take single argument
take three arguments

CS304 Object Oriented Programming 11. Copy constructor is called when:


An object is created in term of pre existence object
An object is created
An object is initialized
None of the given

CS304 Object Oriented Programming 12. Which of the following operator doesn't
take any argument if overloaded?
/
-
+
None of the given choices

CS304 Object Oriented Programming 13. “A fan has wings”. Which type of
relationship exists between fan and wings?
Aggregation
Association
Composition
Inheritance

CS304 Object Oriented Programming 14. What type of relationship exists


between “Account” class and “SavingAccount” class?
Inheritance
Composition
Aggregation
Association

CS304 Object Oriented Programming 15. Select correct line of code for
inheritance relationship between “Nationality” class and “Citizen” class.
“Nationality” is parent class while “Citizen” is child class.
class Citizen: public Nationality
class Nationality: public Citizen
class Citizen:: public Nationality
class Nationality:: public Citizen

CS304 Object Oriented Programming 16.To initialize an array of objects, only


_____________ will be called
Defualt Constructor
Overloaded Constructor
Default Object
None of the above

1. We can have ________ type of member functions in a class.

1. Public
2. Private
3. Protected
4. All of the given
2. Which of the following is NOT casting operator in C++
standard?

1. static_cast
2. var_cast
3. dynamic_cast
4. reinterpret_cast
3. Which of the following types of Inheritance is used to model
"Implemented in terms of" relationship?
1. Public
2. Private
3. Protected
4. Confidential
4. In case of protected inheritance, public members of base class
will be ________ in derived class?

1. private
2. public
3. protected
4. hidden
5. In C++ by default access of classes is ________.

1. Private
2. Protected
3. Public
4. None of the given
6. If there is a pointer p to objects of a base class , and it
contains the address of an object of a derived class, and both
classes contain a virtual member function, ding(), then the
statement p->ding(); will cause the version of ding() in the
________ class to be executed.

1. base
2. derived
3. virtual
4. implemented
7. Suppose we have defined derived class copy constructor but
have not defined base class copy constructor then compiler
will,

1. Use base class default constructor


2. Generate base class copy constructor itself
3. Use base class assignment operator
4. None of the given
8. In case of private inheritance, private members of base class
will be ________ in derived class.

1. private
2. public
3. protected
4. hidden
9. A template argument is preceded by the keyword ________.

1. vector
2. class
3. template
4. type*
10. ________ Binding means that target function for a call is
selected at compile time.

1. Static
2. Dynamic
3. Automatic
4. None of the given
11. In case of public inheritance, protected members of base
class will be ________ in derived class.

1. private
2. public
3. Protected
4. hidden
12. A template provides a convenient way to make a family of

1. variables and data members


2. functions and classes
3. classes and exceptions
4. programs and algorithms
13. Function overriding is done in context of,

1. Single class
2. Single derived class
3. Single base class
4. Derived and base class
14. Which of the following is TRUE.

1. Derived class pointer can be used as Base class pointer


2. Base class pointer can be used as Derived class pointer
3. Both of these options
4. None of the given
15. The default inheritance mode is,

1. Public inheritance
2. Protected inheritance
3. Private inheritance
4. None of the given
16. In Protected Inheritance the public members of base class
become ________ in derived class.

1. Public
2. Private
3. Protected
4. None of the given
17. In resolution order compiler search firstly ________.

1. Generic Template
2. Partial Specialization
3. Complete Specialization
4. Ordinary function
18. Compiler generated copy constructor performs ________.

1. Shallow copy
2. Deep copy
3. Both Shallow and Deep copy
4. None of the given
19. A pure virtual function is a virtual function that
1. causes its class to be abstract.
2. returns nothing.
3. is used in a derived class.
4. takes no arguments.
20. Methodologies to the development of reusable software
relate to ________.

1. Structure programming
2. procedural programming
3. generic programming
4. None of the given
21. In C++ generic programming is done using ________.

1. Procedures
2. Packages
3. Templates
4. None of the given
22. Consider the code below,

class class1{
private:
void func1();
};
class class2 : private class1 {
};
Function func1 of class1 is ________ in class2.

1. public
2. protected
3. private
4. None of the given
23. When derived class has user defined assignment operator.

1. Compiler itself calls base class assignment operator.


2. Compiler itself calls base class copy constructor.
3. Compiler itself calls base class default constructor.
4. Compiler does nothing.
24. A Child class can call constructor of its parent class
through,

1. Its constructor initialization list


2. Its constructor body
3. Both from its constructor initialization list or body
4. Can not call the constructor of its parent class
25. Consider the code below,
class class1{
public:
int i;
};
class class2 : public class1 {
};

Then int member i of class1 is ________ in class2.

1. public
2. protected
3. private
4. None of the given
26. Consider the code below,
class class1{
protected:
int i;
};
class class2 : private class1 {
};

Then int member i of class1 is ________ in class2.

1. public
2. protected
3. private
4. None of the given
27. Static casting is,
1. Implicit way of calling base class functions from derived class
2. Explicit way of calling base class functions from derived class
3. Both of the given
4. None of the given
28. How many objects of a given class may be constructed in
an application?

1. Only one per constructor.


2. As many as the application asks for
3. Only one per class
4. One object per variable
29. The other name of specialization is ________.

1. Restriction
2. Extension
3. Dependency
4. Subtyping
30. How can we differentiate between constructors and
destructors?

1. Destructors have a return type but Constructors do not have


return type.
2. Destructors can't be defined by the programmer, but
Constructors can be defined by the programmer.
3. Destructors are preceded with a tilde (~) symbol, and
constructors are not preceded with any symbol.
4. Destructors are exactly same as Constructors in syntax.
31. How many entities are there in the following scenario?
Ali lives in the house that is near the tree and he also drives
his car.

1. 1
2. 2
3. 3
4. 4
32. Which of the following is True about Destructor?
1. It is used to free memory that is allocated through dynamic
allocation.
2. Free memory allocated using new operator by over self in
destructor.
3. It is used to perform house keeping operations.
4. All of the given
33. How many objects are involved in the N-ary association?

1. More than 1
2. More than 2
3. More than 3
4. More than 4
34. Which of the following can be the behavior of an object
"Usman"?

1. Name
2. Age
3. Address
4. Eat
35. In C++, Composition is a relationship between ________
and ________ objects.

1. Parent, child
2. Base, derived
3. Whole, part
4. All of the given
36. If you have three classes in a C++ program A, B, and C
where class A inherits from class B, then class ________
contains all the characteristics of class ________.

1. B, A
2. A, B
3. A, C
4. B, C
37. In case when we define the function outside the class then
we must use the keyword ________ to make the function
inline.

1. requestin
2. inlineout
3. inline
4. defineinline
38. Mermaid is an example of:

1. Single inheritance
2. Polymorphism
3. Specialization
4. Multiple Inheritance
39. Assignment operators are:

1. Left associative
2. Right associative
3. Left and right associative
4. Non associative
40. Generalization is ________ approach.

1. Bottom-up
2. Top-bottom
3. Right-Left
4. Left-Right
41. The ________ tells the compiler what task the function will
be performing.

1. Function declaration
2. Function calling
3. Function definition
4. None of the given
42. Suppose str1, str2 and str3 are objects of class String.
Choose appropriate declaration of overloaded assignment
operator for the following statement to work correctly.
1. void operator =(const String &);
2. String& operator =(const String &);
3. String& overload =(const String &);
4. void op =(const String &);
43. In operator overloading, which of the following operator
takes one or no argument.

1. ++
2. *
3. %
4. <<
44. Class is blueprint of ________.

1. Interface
2. Class
3. Objects
4. Model
45. Polymorphism makes the system:

1. reusable
2. flexible
3. faster
4. All of the given
46. If class B inherits from class A then it contains all
characteristics of ________.

1. Class B
2. Class A
3. No inheritance
4. None of the given
47. What is meant by multiple inheritance?

1. Deriving a base class from derived class


2. Deriving a derived class from base class
3. Deriving a derived class from more than one base class
4. None of the given
48. In C++, which of the following operator can only be
overloaded as a member function of the class?

1. Equality Operator: ==
2. Inequality Operator: !=
3. Function Operator: ()
4. Stream Extraction Operator: >>
49. Insertion operator is ________ associative.

1. Right to Left
2. Left to Right
3. Left to Left
4. Right to Right
50. In expression c1*c2+c3-c4 which of the following will be
executed in first order?

1. c1*c2
2. c2+c3
3. c3-c4
4. c1-c4
51. Suppose for a class String, assignment operator is
overloaded with following declaration.
void operator =(const String &);
What will happen when we will write following statement in
main()?
str1 = str2 = str3;
Where, str1, str2 and str3 are objects of class String.

1. Program will compile successfully.


2. Compiler will generate compile time error.
3. Run time error will be generated.
4. None of the given
52. Identify the abstract class from the given statement:

"Vehicle class is base class. Bus, Car, and Truck are derived
classes"
1. Vehicle
2. Bus
3. Car
4. Truck
53. Which of the following operators operate on one operand?

1. Binary Operators
2. Unary Operators
3. Ternary Operator
4. All of the given
54. Subtyping means that derived class is behaviorally
________ with the base class.

1. Same
2. Compatible
3. Different
4. Incompatible
55. In ________, Base class can't always be replaced by the
derived class.

1. Aggregation
2. Inheritance
3. Specialization
4. Extension
56. The overloaded '-' operator for Complex class will be called
with reference to ________ in the following statement
Complex C3 = C1 - C2;

1. Complex
2. C1
3. C2
4. C3
57. What is a class?

1. A class is a section of computer memory containing objects


2. A class is a section of the hard disk reserved for object oriented
programs
3. A class is the part of an object that contains the variables
4. A class is a description of a kind of object
58. In polymorphism, messages can be interpreted in different
ways depending upon the ________ class.

1. base
2. derived
3. sender
4. receiver
59. Suppose there is an object of type Person, which of the
following can be considered as one of its attributes?

1. Name
2. Eat
3. Work
4. Sleep
60. Which of the following is True about class?

1. It is a mechanism in C++ to realize objects in a program.


2. It is concrete implementation of objects in C++
3. It is used to create new types in C++ according to our
requirement
4. All of the given
61. In C++, which of the following keywords works only with
constructors?

1. const
2. static
3. explicit
4. virtual
62. Choose correct declaration of overloaded stream insertion
operator for class String as non-member friend function.

1. friend ostream & operator << ();


2. friend void & operator << (ostream & os);
3. friend void operator << (const String & rhs);
4. friend ostream & operator << (ostream & os, const String & s);
63. Which of the following classes are used by Amphibious
vehicle to inherit characteristics?

1. Land Vehicle
2. Water Vehicle
3. Both Land & Water Vehicle
4. None of the given
64. Constructors have ________ return type.

1. int
2. char
3. void
4. no
65. The other name of specialization is ________.

1. Restriction
2. Extension
3. Dependency
4. Subtyping
66. ________ is represented by a line with an unfilled diamond
head towards the container.

1. Inheritance
2. Association
3. Aggregation
4. Composition
67. ________ remain in memory even when all objects of a
class have been destroyed.

1. Static Variables
2. Instance Variables
3. Primitive Variables
4. None of the given
68. Static Data Member is declared ________.

1. Inside the class


2. Outside the class
3. Inside main() method
4. None of the given
69. A good model is ________ related to a real life problem.

1. Loosely
2. Openly
3. Closely
4. Not
70. In which of the following OOP paradigm objects cannot
exist independently?

1. Polymorphism
2. Inheritance
3. Aggregation
4. Composition
71. In order to make any function constant, keyword const is
placed at the ________ of the parameter list.

1. Beginning
2. Middle
3. End
4. None of the given
72. "Student registers Course and Teacher teaches the
Course." is an example of:

1. Binary Association
2. Two way Association
3. Ternary Association
4. N-ary Association
73. Which of the following can be the attribute of an object
"Ali"?
1. Eat
2. Walk
3. Sleep
4. Address
74. Consider the statement "room has chair" Which of the
following type of association exists between room and chair?

1. Inheritance
2. Composition
3. There is no association
4. Aggregation
75. We can access a private static variable through:

1. Static data member


2. Static member function
3. Global data member
4. None of the given
76. Abstraction provides information according to ________.

1. User perspective
2. Owner perspective
3. Random information
4. All information
77. Which of the following concept is more close to
encapsulation?

1. Exception Handling
2. Inheritance
3. Polymorphism
4. Information Hiding
78. How the information hidden within an object can be
accessed?

1. Through its interface


2. Through its private data members
3. Through its private member functions
4. Through both public and private members
79. ________ defines the order of evaluation of an operator in
an expression.

1. Operator Associativity
2. Operator Precedence
3. Arity of Operators
4. None of the given
80. Which of the following is the correct syntax of declaring
static variable "count" of type int?

1. static count int;


2. static int count;
3. int static count;
4. int count static;
81. Defining a function in class body, the compiler treats that
function as:

1. User defined function


2. Static function
3. Recursive function
4. Inline function
82. What is the output of the following code?

int main()
{
int const x = 10;
cout << ++x;
return 0;
}

1. 10
2. 11
3. Error
4. None of the given
83. Which of the following statements best describes the
Constructor?
1. Constructor is used to modify constant data members of the
class.
2. Constructor is used to delete the objects of a class.
3. Constructor is used to initialize the data members of a class.
4. All of the given
84. Consider the following code segment:

class test
{
int a;
int b;
int c;
public:
test():b(5).c(a).a(b){}
}

What will the value of variables a, b, and c after instantiating


an object of above class?

1. 5, 5, 5
2. 5, Junk value, 5
3. Junk value, 5, Junk value
4. Junk value, 5, 5
85. Which of the following is a strong relationship?

1. Inheritance
2. Composition
3. Association
4. Polymorphism

You might also like