Sie sind auf Seite 1von 19

CS304 Object Oriented Programming Final Term

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

7.________ and ______ methods may not be declared abstract.

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)

Constant 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); (pg 145)
Rational_number operator+(Rational_number &obj, double& num);
operator+(double& obj);
12. A class can be identified from a statement by -------------.
Noun (pg 58)
Pronoun
Verb
Adverb
13. The return type of a constructor is of -------------.
Integer
Character
Double
No type (pg74)
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. Abstract classes have ……..object/s, while concrete classes have …………..object/s.
One, One
More than one, more than one

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

18. Consider the following code segment:


void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Assignment

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,

Sub-typing (pg 31)


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 operator 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?

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

6. Which is true about sub-typing in case of inheritance?

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

Static method (Pg. 108)

10. If you do not initialize static variable of int type then it is


automatically initialized with _________.
0 (Pg. 107)
1
-1
Null
11. Which one is not keyword in C++?
operator

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,

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 (Pg. 175)
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 (? : ) (pg 141)
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 (Pg. 53)
Weak
7. Consider a class having name MyClass, what will be the name of this class constructor ?

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

19. Consider the following code segment:


void UserInfo (Complex & C1){
C1=C1;
}
It is an example of:
Assignment
Self assignment (Pg. 151)
Compound assignment
Multiple assignment
20. Subscript operator must be ________ of the class when overloaded.
Static function
Virtual function
Member function (pg 160)
Non member function

1. What is a class?

A class is a section of computer memory containing objects.


A class 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 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
Compiler error
Run-time error
3. Consider the following statement. "Cupboard has books"
What is the relationship between Cupboard and books?

8
CS304 Object Oriented Programming Final Term
Fall-2012
Composition

Aggregation (Pg. 54)


Inheritance
Association

4. Which of the following is directly related to polymorphism?


Const members

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

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 (Pg. 100)
Access and read only
Access, read, and modify

8. Friend functions are ____________ functions of a class.


Object member
Member
Non-member (pg 136)
Static member
9. The return type of a constructor is of -------------.
Integer
Character
Double
No type (Pg. 74)

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(;)

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
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 (Pg. 49)

15. Abstract classes have……..object/s, while concrete classes have …………..object/s.


One, One
More than one, more than one
No, One or more (Pg. 229)
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 (pg 16)

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

1.Which one of the following is not 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 (Pg. )
Keep data separated from code 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 directly related to polymorphism?

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

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.

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

6. Which of the following is a weak relationship between two objects?

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

Object (Pg. 19)


11. "This pointer" does not pass implicitly to __________ functions.
Static member (Pg. 114)
Non-static member
Instance member
Constant member
12. In ____________, a pointer or reference to an object is created inside a class.
Aggregation (Pg. 133)
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 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

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

14. 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

15. Why we should avoid 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 equivalent 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){

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

20. Friend Complex & operator -(Complex & t);


It is the declaration of:
Unary minus member function

Unary minus non member function (Pg. 162)


Unary minus static member function
Unary minus non static member function

19

Das könnte Ihnen auch gefallen