Page
1
CS304 Object Oriented Programming
2012 Fall
1.
Which of the following is the way to extract common behaviour and attributes from
the given classes and make a separate class of those common behaviours and
attributes?
Generalization
Sub
-
typing
Specialization
Extension
2.
Abstraction is a feature of
OOP which enables an object to
-------------
.
Increase Complexity
Decrease Complexity
Increase Modularity
Decrease Modularity
3.
In a class, objects cannot have common __________.
Behaviour
Attributes
States
Names
4.
Which of the following is an exam
ple of multiple inheritances?
Student
Woman
Mermaid
Train
5. A C++ class is similar to a _________.
Structure
Header File
Library File
Function
6. Which of the following is used to free the memory space allocated as a result of object
declaration?
Co
nstructor
New operator
Destructor
Accessor Function
7.________ and ______ methods may not be declared abstract.
Private,Static
Private,Public
Static,Public
Static, Protected
8.
If a static variable is not explicitly initialized at the time of its definitio
n then,
The compiler will give an error message
The compiler will give a warning message
The compiler will initialize it with value Zero.
The program terminates
9.
Object cannot be declared constant if it is required to change the state of its _________.
C
onstant data members
Non
-
constant data members
Page
2
CS304 Object Oriented Programming
2012 Fall
Constant member functions
Static data members
10.
A
friend
function can access a class’s private data without being a ____________.
Static member of the class
None member of the class
Member of the class
Cons
tant member of the class
11. Identify which of the following overloaded operator function’s declaration is
appropriate for the given call?
Rational_number_1 + 2.325
Hint:
Where
Rational_number_1 is an object of user defined class Rational_number.
Rational_
number operator+( Rational_number & obj);
Rational_number operator+(double& obj);
Rational_number operator+(Rational_number &obj, double& num);
operator+(double& obj);
12.
A class can be identified from a statement by
-------------
.
Noun
Pronoun
Verb
Adverb
13.
The return type of a constructor is of
-------------
.
Integer
Character
Double
No type
14.
Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is
overloaded to add obj1 and obj2 using the function call obj1+obj2.
Identify the correct function prototype against the given call?
A operator + ( A &obj);
int + operator();
int operator (plus) ();
A operator(A &obj3);
15. Abstract classes have……..object/s, while concrete classes have …………..object/s.
One, One
More than on
e, more than one
No, One or more
No, One
16.
If MyClass has a destructor its name will be,
MyClass
~MyClass
My~Class
MyClass~
17.
A static member function can be called, even when an object is not __________.
Excecute
Define
Instantiated
Mention
Page
3
CS304 Object Oriented Programming
2012 Fall
18. Con
sider the following code segment:
void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Assignment
Self assignment
Compound assignment
Multiple assignment
19. While overloading the stream insertion operator, the return type must be _________.
Ostream
Istream
Instream
Iostream
20.
To overload subscript operator, it requires one _________ type parameter.
Int
Float
Char
String
CS304
Object Oriented Programming
1.
When the base class cannot be replaced by its derived class then it is called,
Sub
-
typing
Su
per
-
typing
Generalization
Specialization
2.
Suppose that the Test class does not have an overloaded assignment operator. What
happens when an assignment a=b; is given for two Test objects a and b?
The automatic assignment operator is used
The copy constr
uctor is used
Compiler error
Run
-
time error
3. By default, which access level is assigned to members of a class?
Public
Private
Local
Protected
4. In OOP's, advantage of inheritance include all of the given below except,
Provide a useful
conceptual framwork
Reusing the code
Dealing with real world entities
Decrease maintainablity
5. Main problem(s) with multiple inheritance includes _________.
Increased Complexity, Reduced Understanding, Less Reusability
Increased Complexity, Decreased
Code Redundancy, Less Reusability
Increased Complexity, Reduced understanding, Duplicate Features
Increased Complexity, Less Reusability, Duplicate Features
Page
4
CS304 Object Oriented Programming
2012 Fall
6.
Which is true about sub
-
typing in case of inheritance?
In sub
-
typing derived class shows some e
xtended behavior of its parent.
In sub
-
typing derived class shows some restricted behavior of its parent class.
In sub
-
typing derived class should be abstract.
Sub
-
typing has no relation with inheritance
7.
The ______ keyword tells the compiler to substitu
te the code within the function
definition for every instance of a function call.
Virtual
Inline
Instance
Static
8. The function that is automatically called when an object of a class is created is named
as _________.
Constructor
Destr
uctor
Member Functions
Inline Functions
9. Which will be the good example of a method that is shared by all instances of a class?
Virtual method
Overloaded method
Constant method
Static method
10.If you do not initialize static variable of int type then
it is automatically initialized
with _________.
0
1
-
1
Null
11. Which one is not keyword in C++?
operator
B_op
const
using
12. We capture the object attributes and behavior in Object Oriented programming
using
---------------
.
Class
Function
Data Memb
ers
Instances
13. The return type of a constructor is of
-------------
.
Integer
Character
Double
No type
14. For more than one member in initializer list, then we use ________ to separate them.
Dot (.)
Comma (,)
Colon (:)
Page
5
CS304 Object Oriented Programming
2012 Fall
Semicolon(;)
15. Assu
me a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1
-
obj2 to work correctly, if the overloaded
-
operator must
Take two arguments.
Return a value.
Create a named temporary object.
Take four arguments.
16. To convert from a user
-
d
efined class to a basic type, you would most likely use
a conversion operator that’s a member of the class.
a built
-
in conversion operator.
a one
-
argument constructor.
an overloaded = operator.
17.
A generalization
-
specialization relation between classes
are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance
18.
Operator overloading is:
Making C++ operators able to work with objects.
Giving C++ operators more than they can handle.
Giving new meanings to existing Class members.
Maki
ng new C++ operators.
19. The life of sub object is dependant on the life of master class in _____________.
Separation
Composition
Aggregation
Association
20. __________ operator will take only one operand.
New
Const
Int
This
CS304
Object Oriented Prog
ramming
1.
Which one of the following features of OOP is used to deal with only relevant details?
Abstraction
Information hiding
Object
Inheritance
2. Inheritance is a way to
make general classes into more specific classes.
pass arguments to objects of
classes.
improve data hiding and encapsulation.
providing class growth through natural selection.
3. Consider the code below,
class Fred {
public:
Fred();
Page
6
CS304 Object Oriented Programming
2012 Fall
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
A) Fred a
[10]; calls the default constructor 09 times
Fred* p = new Fred[10]; calls the default constructor 10 times
B) Produce an error
C) Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10]; calls the default constructor 11 times
D) Fred a
[10]; calls the default constructor 10 times
Fred* p = new Fred[10]; calls the default constructor 10 times
4. Which operator can not be overloaded?
The relation operator ( >= )
Assignment operator ( = )
Script operator ( [] )
Conditional operator (? : )
5. Abstraction is a feature of OOP which enables an object to
-------------
.
Increase Complexity
Decrease Complexity
Increase Modularity
Decrease Modularity
6. Composition is an example of _________ relationship.
Simple
Complex
Strong
Weak
7. Conside
r a class having name
MyClass
, what will be the name of this class constructor
?
MyClass
Myclass
myClass
myclass
8. The function that is automatically called when an object of a class is created is named
as _________.
Constructor
Destructor
Member Functions
Inline Functions
9. The const member functions uses following specifers __________.
Only access
Only read
Access and read only
Page
7
CS304 Object Oriented Programming
2012 Fall
Access, read, and modify
10. The life of sub object is not dependant on the life of mast
er class in ___________.
Composition
Aggregation
Separation
Abstraction
11. Friend functions are ____________ functions of a class.
Object member
Member
Non
-
member
Static member
12. Suppose obj1 and obj2 are two objects of a user defined class A.
An + operator is
overloaded to add obj1 and obj2 using the function call obj1+obj2.
Identify the correct function prototype against the given call?
A operator + ( A &obj);
int + operator();
int operator (plus) ();
A operator(A &obj3);
13. A generalization
-
specialization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance
14. A real world object’s attributes are represented through,
Member function
Data members
Global variables
Const data members
15. Why we sh
ould avoid the use of friend function/class?
Friend function/class minimizes encapsulation
Difficult to use
Decreases complexity
Increase program code size
16. Which of the following is
NOT
an advantage of information hiding?
Simplifies the model
Restriction to change
Prevents damage from errant external code
Provide direct access to data members
17. Assume that a user wants to count, how many objects are created for a particular
class, which one will be most suitable to perform this task:
C
onst data member
Non static data member
Static data member
Global data member
18. ___________, which means if A declares B as its friend it does NOT mean that A can
access private data of B. It only means that B can access all data of A.
Friendship is one
way only
Friendship is two way only
Page
8
CS304 Object Oriented Programming
2012 Fall
NO Friendship between classes
Any kind of friendship
19. Consider the following code segment:
void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Assignment
Self assignment
Compound assignment
Multiple assignment
20. Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function
Non member function
CS304
Object Oriented Programming
1.
What is a class?
A class is a section of computer memory containing objects.
A cl
ass is a section of the hard disk reserved for object oriented programs
A class is the part of an object that contains the variables.
A class is a description of a kind of object.
2.
Suppose that the Test class does not have an overloaded assignment operat
or. What
happens when an assignment a=b; is given for two Test objects a and b?
The automatic assignment operator is used
The copy constructor is used
Compiler error
Run
-
time error
3. Consider the following statement.
"Cupboard has books"
What is t
he relationship between Cupboard and books?
Composition
Aggregation
Inheritance
Association
4
.
Which of the following is directly related to polymorphism?
Const members
Overriding
Static members
Const members functions
5.
The constructor of a class is c
alled when
--------------
.
An object is change its state
Page
9
CS304 Object Oriented Programming
2012 Fall
An object is executed
An object is created
An object is destroyed
6.
Which will be the good example of a method that is shared by all instances of a class?
Virtual method
Overloaded method
Constant
method
Static method
7.
The const member functions uses following specifers __________.
Only access
Only read
Access and read only
Access, read, and modify
8. Friend functions are ____________ functions of a class.
Object member
M
ember
Non
-
member
Static member
9. The return type of a constructor is of
-------------
.
Integer
Character
Double
No type
10. For more than one member in initializer list, then we use ________ to separate them.
Dot (.)
Comma (,)
Colon (:)
Se
micolon(;)
11. Given the following class
class Base{
int Age=33;
}
How you can improve above class with respect to accessing the field Age?
Define the variable Age as private
Define the variable Age as protected
Define the variable Age as private
and create a get method that returns it and a
set method that updates it
Define the variable Age as protected and create a set method that returns it and a get
method that updates it
12. A normal C++ operator that acts in special ways on newly defined data
types is said
to be
Glorified.
Encapsulated.
Classified.
Overloaded.
13. To convert from a user
-
defined class to a basic type, you would most likely use
Page
10
CS304 Object Oriented Programming
2012 Fall
a conversion operator that’s a member of the class.
a built
-
in conversion operator.
a one
-
argument
constructor.
an overloaded = operator.
14. A generalization
-
specialization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance
15. Abstract classes have……..object/s, while concrete classes have …………..object/s
.
One, One
More than one, more than one
No, One or more
No, One
16. Hiding details of an object from the other parts of a program is done by which
principle of OOP?
Obfustication
Data Mining
Compilation
Encapsulation
17.
Graphical representation of the cla
sses and objects is called object model it
shows
-------
.
Class name, Attributes, States, Operations
Class name, Attributes, Operations, Methods
Class name, Attributes, Operations, Behaviour
Class name, Attributes, Operations, Relationship
18. Consider the
following function:
void multiplication (int x, int y);
If we overloaded the above function, then it will require ………. operands.
One
Two
Three
Four
19. Consider the following code segment:
void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Multip
le assignment
Assignment
Self assignment
Compound assignment
20. While overloading the stream extraction operator, the return type must be _________.
Ostream
Iostream
Istream
Instream
Page
11
CS304 Object Oriented Programming
2012 Fall
CS304
Object Oriented Programming
1.Which one of the following is no
t a major element of an Object Model?
Abstraction
Encapsulation
Persistence
Hierarchy
2. Encapsulation is a feature of Object Oriented Programming which means,
Keep data separated from code
Keep data and code in a single place
Keep data separated from co
de and also keep data and code in a single place
Reusing code by creating new classes from previously created classes
3. Reusability can be achieved through __________.
Inheritance
Aggregation
Association
Abstraction
4.
Which of the following is directl
y related to polymorphism?
Const members
Overriding
Static members
Const members functions
5. Which of the class’s members are available to every one?
Public
Private
Protected
Internal
6. A member function having the same name as the class name precede
d by a tilde (~)
sign is called _______.
Constructor
Getter
Setter
Destructor
7. Which of the following is used to free the memory space allocated as a result of object
declaration?
Constructor
New operator
Destructor
Accessor Function
8. __________ provid
e the facility to access the data member.
Accesser function
Private function
Inline function
Constructor
Page
12
CS304 Object Oriented Programming
2012 Fall
9. What will be the value of the variable data and data2 respectively, If the function
below is called 4 times?
void func()
{
static int data = 4
;
int data2 = 4;
++data;
++data2;
}
8, 5
5, 8
5, 5
7, 5
10. In ____________, a pointer or reference to an object is created inside a class.
Aggregation
Composition
Separation
Association
11. Identify which of the following overloaded operator function’s
declaration is
appropriate for the given call?
Rational_number_1 + 2.325
Hint:
Where
Rational_number_1 is an object of user defined class Rational_number.
Rational_number operator+( Rational_number & obj);
Rational_number operator+(double& obj);
Rational_n
umber operator+(Rational_number &obj, double& num);
operator+(double& obj);
12. We capture the object attributes and behavior in Object Oriented programming
using
---------------
.
Instances
Class
Function
Data Members
13. A normal C++ operator that act
s in special ways on newly defined data types is said
to be
Glorified.
Encapsulated.
Classified.
Overloaded.
14. Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is
overloaded to add obj1 and obj2 using the function call obj1
+obj2.
Identify the correct function prototype against the given call?
A operator + ( A &obj);
int + operator();
int operator (plus) ();
A operator(A &obj3);
Page
13
CS304 Object Oriented Programming
2012 Fall
15. A generalization
-
specialization relation between classes are implemented using
Data hiding
F
riend classes
Encapsulation
Inheritance
16. The technique in which we visualize our programming problems according to real
life’s problems is called_________.
Structured programming
Object oriented programming
Procedural programming
Sequential pro
gramming
17. How many objects for a class can be constructed in an application?
Only one per constructor.
As many as the application asks for.
Only one per class.
One object per variable.
18. We ………… change the evaluation precedence of operators through
operator
overloading.
Can
Can not
Only
Just
19. Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function
Non member function
20. friend Complex & operator
-
(Complex & t);
It is the declaration of:
Unary minus member function
Unary minus non member function
Unary minus static member function
Unary minus non static member function
CS304
Object Oriented Programming
1. Inheritance is a way to
organize data.
pass arguments to objects of classes.
add
features to existing classes without rewriting them.
improve data
-
hiding and encapsulation.
Page
14
CS304 Object Oriented Programming
2012 Fall
2.
The ability to derive a class from more than one classes is called,
Single inheritance
Encapsulation
Multiple inheritance
Polymorphism
3.
For classes with co
mmon behavior, you can save effort by placing the common
behavior in a
__________
.
Derived Class
Base class
Deprived Class
Named class
4.
If
Rollno
is a
const
data member of a class
student
then which definition is correct
for the member function
show ()
i
nt show() const { return Rollno; }
void show() const { return Rollno; }
int show() const { return Rollno + 50; }
int show(num) const { Rollno = num; }
5.
An overloaded operator always requires __________ argument than its number of
operands.
One less
On
e most
Two less
Three most
6.
Which of the following is a weak relationship between two objects?
Inheritance
Composition
Aggregation
Association
7.The constructor of a class is called when
--------------
.
An object is change its state
An object is execute
d
An object is created
An object is destroyed
8. The function that is automatically called when an object of a class is created is named
as _________.
Constructor
Destructor
Member Functions
Inline Functions
9. Which of the following is u
sed to free the memory space allocated as a result of object
declaration?
Constructor
New operator
Destructor
Accessor Function
Page
15
CS304 Object Oriented Programming
2012 Fall
10. Separation of implementation from interface provides the facility to restrict the
_________ from direct access.
Data membe
r
Data function
Class
Object
11. "This pointer" does not pass implicitly to __________ functions.
Static member
Non
-
static member
Instance member
Constant member
12. In ____________, a pointer or reference to an object is created inside a class.
Aggregat
ion
Composition
Separation
Association
13. A class can be identified from a statement by
-------------
.
Noun
Pronoun
Verb
Adverb
14. By default all members of a class are,
Public
Protected
Private
Public & protected
15. Graphical representation of t
he classes and objects is called object model it shows
---
----
.
Class name, Attributes, States, Operations
Class name, Attributes, Operations, Methods
Class name, Attributes, Operations, Behaviour
Class name, Attributes, Operations, Relationship
16. Why we
should avoid the use of friend function/class?
Friend function/class minimizes encapsulation
Difficult to use
Decreases complexity
Increase program code size
17. Operator overloading is:
Making C++ operators able to work with objects.
Giving C++ ope
rators more than they can handle.
Giving new meanings to existing Class members.
Making new C++ operators.
18. Which of the following operator can not be overloaded?
Scope
resolution operator
( :: )
Insertion operator ( << )
Extraction operator ( >> )
T
he relation operator ( > )
Page
16
CS304 Object Oriented Programming
2012 Fall
19 Consider the following code segment:
void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Assignment
Self assignment
Compound assignment
Multiple
assignments
20
. Subscript
operator must be ________ of the class when o
verloaded.
Static function
Virtual function
Member function
Non member function
CS304
Object Oriented Programming
1. Which one of the following features of OOP is used to derive a class from another?
Encapsulation
Polymorphism
Data hiding
Inheritance
2.
Which sentence clearly defines an object?
one instance of a class.
another word for a class.
a class with static methods.
a method that accesses class attributes.
3.
If
Rollno
is a
const
data member of a class
student
then which definition is correct
for t
he member function
show ()
int show() const { return Rollno; }
void show() const { return Rollno; }
int show() const { return Rollno + 50; }
int show(num) const { Rollno = num; }
4.
Suppose that the Test class does not have an overloaded assignment oper
ator. What
happens when an assignment a=b; is given for two Test objects a and b?
The automatic assignment operator is used
The copy constructor is used
Compiler error
Run
-
time error
5. Abstract class has _______.
Zero Instances
One Instance
Two Inst
ances
Many Instances
6. Consider a class having name
MyClass
, what will be the name of this class constructor
?
MyClass
Myclass
myClass
myclass
Page
17
CS304 Object Oriented Programming
2012 Fall
7. Which of the following is used to free the memory space allocated as a result of object
declaration?
Construc
tor
New operator
Destructor
Accessor Function
8. The const member functions uses following specifers __________.
Only access
Only read
Access and read only
Access, read, and modify
9. What will be the value of the variable data and da
ta2 respectively, If the function
below is called 4 times?
void func()
{
static int data = 4;
int data2 = 4;
++data;
++data2;
}
8, 5
5, 8
5, 5
7, 5
10. Object cannot be declared constant if it is required to change the state of its _________.
Constant data
members
Non
-
constant data members
Constant member functions
Static data members
11. In order
to free
the memory occupied by the object, we use
-------------
.
Constructor
Destructor
Shallow Copy
Deep Copy
12. The property in which existing class
is modified to form a new class is called………..
Polymorphism
Inheritance
Encapsulation
Information hiding
13. In inheritance hierarchy which one is on the top?
Subtyping
Specialization
Extension
Generalization
14. Graphical representation of the classes a
nd objects is called object model it shows
---
----
.
Class name, Attributes, States, Operations
Class name, Attributes, Operations, Methods
Class name, Attributes, Operations, Behaviour
Page
18
CS304 Object Oriented Programming
2012 Fall
Class name, Attributes, Operations, Relationship
15. Why we should avoi
d the use of friend function/class?
Friend function/class minimizes encapsulation
Difficult to use
Decreases complexity
Increase program code size
16. In the following operators, the _____ operator can be overloaded.
%
##
?:
.
17. C2+C1 is equivale
nt to ___________, when plus operator is overloaded, and C2, C1 are
objects.
C1.operator + (C2)
C1.operator + (C1)
C2.operator + (C1)
C2.operator + (C2)
18
. Consider
the following code segment:
Void
UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
As
signment
Self assignment
Compound assignment
Multiple assignment
19.
To overload subscript operator, it requires one _________ type parameter.
Int
Float
Char
String
20.
friend Complex & operator
-
(Complex & t);
It is the declaration of:
Unary minus memb
er function
Unary minus non member function
Unary minus static member function
Unary minus non static member function
CS304
Object Oriented Programming
1.
Encapsulation means,
Extending the behavior of class in another class
Data and behaviour are tightl
y coupled within an entity
One entity takes all the attributes and operations of the other
Taking out the common features and put those in a separate class
2. Using encapsulation we can achieve,
Information hiding, least interdependencies, implementation i
ndependence
Least interdependencies, information hiding, inheritance
Implementation independence, polymorphism, information hiding
Inheritance, least interdependencies, information hiding
Page
19
CS304 Object Oriented Programming
2012 Fall
03. Abstraction is a feature of OOP which enables an object to
-----
--------
.
Increase Complexity
Decrease Complexity
Increase Modularity
Decrease Modularity
04.
Which of the following is an example of multiple inheritances?
Student
Woman
Mermaid
Train
5.
Which of the following is directly related to polymorphism
?
Const members
Overriding
Static members
Const members functions
6. The ________ relationship indicates that an object contains other objects.
Implemented in terms of
'has
-
a'
'is a'
'be
-
a'
07. Destructors are called in _______ order as constructor
s are called.
Same
Reverse
Parallel
Different
08.
A non
-
static member function can be called only after ___________ the object of that
class.
Instantiating
Executing
Defining
Opening
9.
Constant Objects _______ change its state.
Can
Cannot
May be or may not be
Must
10. A
friend
function can access a class’s private data without being a ____________.
Static member of the class
None member of the class
Member of the class
Constant member of the class
11shallow copy performs _______ c
opy.
Bitwise
Pagewise
Bytewise
Page
20
CS304 Object Oriented Programming
2012 Fall
Word by word
12. In order to free the memory occupied by the object, we use
-------------
.
Constructor
Destructor
Shallow Copy
Deep Copy
13. A normal C++ operator that acts in special ways on newly defined
data types is said
to be
Glorified.
Encapsulated.
Classified.
Overloaded.
14. A generalization
-
specialization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance
15.
In information hiding ………………is/are kept h
idden from outer world.
State
State, behaviour
Behaviour
Object
16. We can get only one unique value which can be used by all the objects of that class
by the use of,
Static variables
Dynamic variables
Instance variables
Data members
17. Operator overloadi
ng is:
Making C++ operators able to work with objects.
Giving C++ operators more than they can handle.
Giving new meanings to existing Class members.
Making new C++ operators.
18. Which of the following operator can not be overloaded?
Scope resolution
operator ( :: )
Insertion operator ( << )
Extraction operator ( >> )
The relation operator ( > )
19.
Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function
Non member function
20.friend Complex
& operator
-
(Complex & t);
It is the declaration of:
Unary minus member function
Unary minus non member function
Unary minus static member function
Page
21
CS304 Object Oriented Programming
2012 Fall
Unary minus non static member function
CS304
Object Oriented Programming
.1. Three main characteristics o
f
"Object Oriented programming"
are,
encapsulation, dynamic binding, polymorphism
polymorphism, overloading, overriding
encapsulation, inheritance, dynamic binding
encapsulation, inheritance, polymorphism
2.
For classes with common behavior, you can save e
ffort by placing the common
behavior in a
__________
.
Derived Class
Base class
Deprived Class
Named class
03.
The phenomena of single method having different forms is called,
Data hiding
Data processing
Encapsulation
Polymorphism
04.
The property of an obj
ect which distinguish it from other objects is called,
Messages
Identity
Interface
Behavior
05.
When is a constructor called?
Each time the constructor identifier is used in a program statement
During the instantiation of a new object
During the constructi
on of a new class
At the beginning of any program execution
06.
Using encapsulation we can achieve,
Information hiding, least interdependencies, implementation independence
Least interdependencies, information hiding, inheritance
Implementation independenc
e, polymorphism, information hiding
Inheritance, least interdependencies, information hiding
07. Which of the following is an example of multiple inheritances?
Student
Woman
Mermaid
Train
Page
22
CS304 Object Oriented Programming
2012 Fall
08.
The ______ keyword tells the compiler to substitute the
code within the function
definition for every instance of a function call.
Virtual
Inline
Instance
Static
09.
Constant Objects _______ change its state.
Can
Cannot
May be or may not be
Must
10.Object cannot be declared constant if it is required
to change the state of its _________.
Constant data members
Non
-
constant data members
Constant member functions
Static data members
11.
The members of a class that can be accessed without creating the object of the class
is called_______.
Priv
ate member
Data Member
Public Member
Static Member
12.
Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1
-
obj2 to work correctly, if the overloaded
-
operator must
Take two arguments.
Return a value.
Create a named tempor
ary object.
Take four arguments.
13.
Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is
overloaded to add obj1 and obj2 using the function call obj1+obj2.
Identify the correct function prototype against the given call?
A oper
ator + ( A &obj);
int + operator();
int operator (plus) ();
A operator(A &obj3);
14.
The pointer and the memory it points to will be copied in …………..copy.
Deep copy
Shallow copy
Bitwise copy
Byte wise copy
15.
A static member function cannot have access to
the _____ pointer of the class.
Dangling
This
Reference
Null
Page
23
CS304 Object Oriented Programming
2012 Fall
16. Which of the following is
NOT
an advantage of information hiding?
Simplifies the model
Restriction to change
Prevents damage from errant external code
Provide direct access to
data members
17.
Assume that a user wants to count, how many objects are created for a particular
class, which one will be most suitable to perform this task:
Const data member
Non static data member
Static data member
Global data member
18.
Operator over
loading is:
Making C++ operators able to work with objects.
Giving C++ operators more than they can handle.
Giving new meanings to existing Class members.
Making new C++ operators.
19.
While overloading the stream insertion operator, the return type m
ust be _________.
Ostream
Istream
Instream
Iostream
20.
Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function
Non member function
1.
When the base class can not be replaced by its derived class t
hen it is called,
Sub
-
typing
Super
-
typing
Generalization
Specialization
2.
Suppose that the Test class does not have an overloaded assignment operator. What
happens when an assignment a=b; is given for two Test objects a and b?
The automatic assignment op
erator is used
The copy constructor is used
Compiler error
Run
-
time error
3.
By default, which access level is assigned to members of a class?
Public
Private
Local
Protected
4.
In OOP's, advantage of inheritance include all of the given below except,
Provide a useful conceptual framwork
Reusing the code
Dealing with real world entities
Page
24
CS304 Object Oriented Programming
2012 Fall
Decrease maintainablity
5.
Main problem(s) with multiple inheritance includes _________.
Increased Complexity, Reduced Understanding, Less Reusability
Increased Complexity, Decreased Code Redundancy, Less Reusability
Increased Complexity, Reduced understanding, Duplicate Features
Increased Complexity, Less Reusability, Duplicate Features
6.
Which is true about sub
-
typing in case of inheritance?
In sub
-
ty
ping derived class shows some extended behavior of its parent.
In sub
-
typing derived class shows some restricted behavior of its parent class.
In sub
-
typing derived class should be abstract.
Sub
-
typing has no relation with inheritance
7.
The ______ keyword
tells the compiler to substitute the code within the function
definition for every instance of a function call.
Virtual
Inline
Instance
Static
8.
The function that is automatically called when an object of a class is created is named
as _________.
Constructor
Destructor
Member Functions
Inline Functions
9. Which will be the good example of a method that is shared by all instances of a class?
Virtual method
Overloaded method
Constant method
Static method
10.
If you do not initialize s
tatic variable of int type then it is automatically initialized
with _________.
0
1
-
1
Null
11.
Which one is not keyword in C++?
operator
B_op
const
using
12.
We capture the object attributes and behavior in Object Oriented programming
using
---------------
.
Class
Function
Data Members
Instances
Page
25
CS304 Object Oriented Programming
2012 Fall
13.
The return type of a constructor is of
-------------
.
Integer
Character
Double
No type
14.
For more than one member in initializer list, then we use ________ to separate them.
Dot (.)
Comma (,)
Colon (:)
Semicolon(;)
15.
Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1
-
obj2 to work correctly, if the overloaded
-
operator must
Take two arguments.
Return a value.
Create a named temporary object.
Take four argume
nts.
16.
To convert from a user
-
defined class to a basic type, you would most likely use
a conversion operator that’s a member of the class.
a built
-
in conversion operator.
a one
-
argument constructor.
an overloaded = operator.
17.
A generalization
-
specia
lization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance
18.
Operator overloading is:
Making C++ operators able to work with objects.
Giving C++ operators more than they can handle.
Giving new meanings
to existing Class members.
Making new C++ operators.
19. The life of sub object is dependant on the life of master class in _____________.
Separation
Composition
Aggregation
Association
20.
__________ operator will take only one operand.
New
Const
In
t
This
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο