A10.1-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
: JULY 2005
NOTE:
1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and PART TWO contains FOUR questions.
2. PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to the question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be supplied at the table when the answer sheet for PART ONE is returned. However, candidates who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE-40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1 x 10)
1.1 Which of the following would be an invalid class declaration header for a derived class d, with base classes b1 and b2?
A) class d: public b2, public b1
B) class d: class b2, class b1
C) class d: public b2, b1
D) class d: b2,b1
1.2 A class hierarchy
A) shows the same relationship as an organization chart
B) describe “ has a” relationship
C) describe “is a kind of” relationship
D) shows the same relationships as a family tree.
1.3 An array element is accessed using
A) A FIFO approach
B) the operator
C) a member Name
D) An index number
1.4 When a language has the capability to produce new data types, it is said to be a
A) reprehensible
B) encapsulated
C) overloaded
D) extensible
1.5 The new operator
A) returns a pointer to a variable
B) creates a variable called new
C) obtains memory for a new variable
D) tells how much memory is available
1.6 A copy constructor is invoked when
A) a function returns by value
B) an argument is passed by value
C) a function returns by reference
D) an argument is passed by reference
1.7 A friend function can be used to
A) avoid arguments between classes
B) allow access to classes whose source code is unavailable
C) allow one class to access an unrelated class
D) Increase the reusability of an overloaded operator
1.8 A default argument has value, that
A) may be supplied by the calling program
B) may be supplied by the function
C) must have constant value
D) must have a variable value
1.9 The break statement causes an exit
A) only from the innermost loop
B) only from the outermost loop
C) from all loops and switches
D) from the innermost loop and switch
1.10 How many constructors can a class have?
A) 0
B) 1
C) 2
D) any number
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “tear-off” sheet attached to the question paper, following instructions therein. (1 x 10)
2.1 A variable can be tied with several references.
2.2 It is possible to create an array references.
2.3 Object oriented programming language permit functional and data abstraction.
2.4 A pointer to a base class can point to the objects of a derived class.
2.5 A copy constructor could be defined to copy only part of an object is data.
2.6 Scope Resolution Operator (::) could be overloaded in C++.
2.7 Pure virtual function can never have a body.
2.8 A friend function can access a class’s private data without being a member of the class.
2.9 Private members of the base class can be accessed by derived class members’ function/objects of derived class.
2.10 The exception handling mechanism is supposed to handle compile time errors.
3. Match words and phrases in column X with the closest related meaning/ word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 An abstract class A. is used to access a member when we use pointers to both the object and member
3.2 Exception B. is one that is not used to create objects
3.3 Derived class C. can be used to combine similar function into one
3.4 Protected D. makes a program run faster
3.5 Scope resolution Operator E. is runtime anomalies that a program may encounter while executing
3.6 Inline function F. inherits data members and member functions from their base classes.
3.7 Constructor G. is a visibility modifier
3.8 Object H. is a basic run time entity in an Object-Oriented System
3.9 Default arguments I. is a process of binding of data and functions together into a single class-type variable
3.10 Encapsulation J. may contain any number of arguments
K. is a process of making an operator to exhibit different behaviors in different instances
L. can not be overloaded
4. Each statement below has blank space to fit one of the word(s) or phrases in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1 x 10)
A. inheritance B. protected C. polymorphism
D. destructor E. exception F. template
G. private H. inline I. derived
J. friend K. constructor L. encapsulation
M. protected N. destructor O. object
4.1 ____________ function is similar to #define macros.
4.2 ____________ is a process of creating new classes from an existing class.
4.3 Bundling of data and functions together is called _____________.
4.4 The ________ is a special member function for automatic initialization of an object.
4.5 _______ is used to design a single class/function that operates on the data of many types instead to create a separate class/function for each type.
4.6 _________ refers to any unusual condition in a program. It is used to notify error to a caller.
4.7 A(n) _________ class can access private members of another class.
4.8 To be accessed from a member function of the derived class, data or functions in the class must be public or __________.
4.9 The ability of a function or operator act in different ways on different types is called ___________.
4.10 The ___________ is used to de-allocate memory that was allocated for an object. For more questions papers visit www.DoeaccOnline.com, www.IgnouOnline.com
PART TWO
(Answer ANY FOUR questions)
5.
a) What is polymorphism? How can we achieve compile time and run-time polymorphism?
b) Define a class for date with three variables for day, month, year and functions for getting data and displaying data on the screen. Write constructors with and without arguments for the class and destructor that sets values to zero for all three variables. Define object of the class in main and call the write functions using this object.
(5+10)
6.
a) Explain with example a template class.
b) What is meant by exceptions? How an exception is handled in C++? Bring out the advantages of using various exceptions handling mechanism.
c) What do you mean by overloading of a function? When do we use this concept?
(5+5+5)
7.
a) Describe the basic concepts of Object Oriented Programming and bring out the advantages of OOP.
b) Write down characteristics of friend function and constructor.
c) Why virtual function is required? Explain with suitable example.
(5+5+5)
8.
a) Write a program-using pointer to copy all the characters from string s1 to string s2.
b) What is memory leakage? Suggest and implement an approach to trace memory leakage.
c) How do you create an abstract class? Explain it with example.
(5+5+5)
9.
a) Explain the significance of friend function and friend class with proper example. Also explain how a friend function behaves like a bridge between two classes?
b) Explain pointer with suitable example.
c) Differentiate between structure and class?
d) What is containership and how does it differ from inheritance?
(5+3+4+3)