Beruflich Dokumente
Kultur Dokumente
Fall-2012
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 (pg 29)
Sub-typing
Specialization
Extension
2. Abstraction is a feature of OOP which enables an object to -------------.
Increase Complexity
Decrease Complexity (pg 21)
Increase Modularity
Decrease Modularity
3. In a class, objects cannot- have common __________.
Behaviour
Attributes
States
Names
4. Which of the following is an example of multiple inheritances?
Student
Woman (Lecture 5)
Mermaid
Train
5. A C++ class is similar to a _________.
Structure (pg65)
Header File
Library File
Function
6. Which of the following is used to free the memory space allocated as a result of object
declaration?
Constructor
New operator
Destructor (pg 81)
Accessor Function
1
CS304 Object Oriented Programming Final Term
Fall-2012
Private,Static
Private,Public
Static,Public
Static, Protected
8. If a static variable is not explicitly initialized at the time of its definition then,
The compiler will give an error message
The compiler will give a warning message
The compiler will initialize it with value Zero. (pg 107 )
The program terminates
9. Object cannot be declared constant if it is required to change the state of its _________.
Constant data members (pg 105)
Non-constant data members
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 (pg 135)
2
CS304 Object Oriented Programming Final Term
Fall-2012
No, One or more
No, One
16. If MyClass has a destructor its name will be,
MyClass
~MyClass (reference 232)
My~Class
MyClass~
17. A static member function can be called, even when an object is not __________.
Excecute
Define
Instantiated
Mention
Self assignment
Compound assignment
Multiple assignments
19. While overloading the stream insertion operator, the return type must be _________.
Ostream (pg 156)
Istream
Instream
Iostream
20. To overload subscript operator, it requires one _________ type parameter.
Int (pg 160)
Float
Char
String
1. When the base class cannot be replaced by its derived class then it is called,
3
CS304 Object Oriented Programming Final Term
Fall-2012
Public
Private
Local
Protected
4. In OOP's, advantage of inheritance include all of the given below except,
Provide a useful conceptual framework
Reusing the code (pg 26)
Dealing with real world entities
Decrease maintainability
5. Main problem(s) with multiple inheritances includes _________.
Increased Complexity, Reduced Understanding, Less Reusability
Increased Complexity, Decreased Code Redundancy, Less Reusability
Increased Complexity, Reduced understanding, Duplicate Features (pg45)
Increased Complexity, Less Reusability, Duplicate Features
In sub-typing derived class shows some extended behavior of its parent. (Pg. )
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 (Pg. 72)
Instance
Static
8. The function that is automatically called when an object of a class is created is named as
_________.
Constructor (Pg. 74)
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
4
CS304 Object Oriented Programming Final Term
Fall-2012
B_op
const
using
12. We capture the object attributes and behavior in Object Oriented programming using------
---------.
Class (pg 15)
Function
Data Members
Instances
13. The return type of a constructor is of -------------.
Integer
Character
Double
No type (pg 74)
14. For more than one member in initializes list, then we use ________ to separate them.
Dot (.)
Comma (,) (pg 104)
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 arguments.
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. (pg168)
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 (pg 49)
18. Operator overloading is:
Making C++ operators able to work with objects.
Giving C++ operators more than they can handle. (pg 139)
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 (Pg. 120)
Aggregation
Association
20. __________ operator will take only one operand.
New
Const
Int
5
CS304 Object Oriented Programming Final Term
Fall-2012
This
1. Which one of the following features of OOP is used to deal with only relevant details?
Abstraction (pg 23)
Information hiding
Object
Inheritance
2. Inheritance is a way to
make general classes into more specific classes. (pg 27)
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();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
6
CS304 Object Oriented Programming Final Term
Fall-2012
MyClass
Myclass
myClass
myclass
8. The function that is automatically called when an object of a class is created is named as
_________.
Constructor (Pg. 74)
Destructor
Member Functions
Inline Functions
9. The const member functions uses following specifers __________.
Only access
Only read (Pg. 100)
Access and read only
Access, read, and modify
10. The life of sub object is not dependant on the life of master class in ___________.
Composition
Aggregation (pg 134)
Separation
Abstraction
11. Friend functions are ____________ functions of a class.
Object member
Member
Non-member (pg 136)
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(); (pg 143)
int operator (plus) ();
A operator(A &obj3);
13. A generalization-specialization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance (pg 49)
14. A real world object’s attributes are represented through,
Member function
Data members(Pg. 14)
Global variables
Const data members
15. Why we should avoid the use of friend function/class?
Friend function/class minimizes encapsulation (Pg. 153)
Difficult to use
Decreases complexity
Increase program code size
16. Which of the following is NOT an advantage of information hiding?
Simplifies the model
7
CS304 Object Oriented Programming Final Term
Fall-2012
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. ___________, 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 (Pg.292 )
Friendship is two way only
NO Friendship between classes
Any kind of friendship
1. What is a class?
8
CS304 Object Oriented Programming Final Term
Fall-2012
Composition
Overriding (pg )
Static members
Const members functions
5. The constructor of a class is called when --------------.
An object is change its state
An object is executed
An object is created (pg 74)
An object is destroyed
Static method
7. The const member functions uses following specifers __________.
Only access
Only read (Pg. 100)
Access and read only
Access, read, and modify
9
CS304 Object Oriented Programming Final Term
Fall-2012
10. For more than one member in initializer list, then we use ________ to separate them.
Dot (.)
Comma (,) (Pg. 104)
Colon (:)
Semicolon(;)
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
a conversion operator that’s a member of the class.
a built-in conversion operator.
a one-argument constructor.
an overloaded = operator.
10
CS304 Object Oriented Programming Final Term
Fall-2012
17. Graphical representation of the 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
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:
Multiple assignment
Assignment
Self assignment (Pg. 151)
Compound assignment
20. While overloading the stream extraction operator, the return type must be _________.
Ostream
Iostream
Istream
Instream
11
CS304 Object Oriented Programming Final Term
Fall-2012
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 preceded by a tilde (~) sign is
called _______.
Constructor
Getter
Setter
Destructor (pg 92)
7. Which of the following is used to free the memory space allocated as a result of object
declaration?
Constructor
New operator
Destructor (Pg. 81)
Accessor Function
8. __________ provide the facility to access the data member.
Accesser function (pg 68)
Private function
Inline function
Constructor
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 (Pg. 134)
Composition
Separation
Association
12
CS304 Object Oriented Programming Final Term
Fall-2012
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); (Pg. 145)
Rational_number operator+(Rational_number &obj, double& num);
operator+(double& obj);
12. We capture the object attributes and behavior in Object Oriented programming using------
---------.
Instances
Class (pg 15)
Function
Data Members
13. A normal C++ operator that acts 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) (); (pg 143)
A operator(A &obj3);
15. A generalization-specialization relation between classes are implemented using
Data hiding
Friend classes
Encapsulation
Inheritance (pg 49)
16. The technique in which we visualize our programming problems according to real life’s
problems is called_________.
Structured programming
Object oriented programming (pg 9)
Procedural programming
Sequential programming
13
CS304 Object Oriented Programming Final Term
Fall-2012
Can
Can not
Only
Just
19. Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function (Pg. 160)
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
1. Inheritance is a way to
organize data.
pass arguments to objects of classes.
add features to existing classes without rewriting them. (pg 27)
improve data-hiding and encapsulation.
2. The ability to derive a class from more than one classes is called,
Single inheritance
Encapsulation
Multiple inheritance
Polymorphism
3. For classes with common behavior, you can save effort by placing the common behavior in
a __________.
Derived Class
Base class (pg 29)
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 ()
int 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 (pg 896)
One most
Two less
Three most
Inheritance
Composition
Aggregation
14
CS304 Object Oriented Programming Final Term
Fall-2012
Association
7.The constructor of a class is called when --------------.
An object is change its state
An object is executed
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 (Pg. 74)
Destructor
Member Functions
Inline Functions
9. Which of the following is used to free the memory space allocated as a result of object
declaration?
Constructor
New operator
Destructor (Pg. 92)
Accessor Function
10. Separation of implementation from interface provides the facility to restrict the
_________ from direct access.
Data member
Data function
Class
15
CS304 Object Oriented Programming Final Term
Fall-2012
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++ 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 ( :: ) (pg 141)
Insertion operator ( << )
Extraction operator ( >> )
The relation operator ( > )
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
1. Which one of the following features of OOP is used to derive a class from another?
Encapsulation
Polymorphism
Data hiding
Inheritance (pg 25)
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 the
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 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 constructor is used
16
CS304 Object Oriented Programming Final Term
Fall-2012
Compiler error
Run-time error
5. Abstract class has _______.
Zero Instances (there is no object)
One Instance
Two Instances
Many Instances
6. Consider a class having name MyClass, what will be the name of this class constructor ?
MyClass
Myclass
myClass
myclass
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. The const member functions uses following specifers __________.
Only access
Only read
Access and read only (Pg. 106)
Access, read, and modify
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. 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
17
CS304 Object Oriented Programming Final Term
Fall-2012
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
C2.operator + (C1)
C2.operator + (C2)
18
CS304 Object Oriented Programming Final Term
Fall-2012
C1=C1;
}
It is an example of:
Assignment
Self assignment
Compound assignment
Multiple assignment
19. To overload subscript operator, it requires one _________ type parameter.
Int
Float
Char
String
19