POKHARA UNIVERSITY
Level: Bachelor Semester – Spring Year : 2006
Programme: BE Full Marks: 100
Course: Object Oriented Programming in C++ Time : 3hrs.
Candidates are required to give their answers in their own words as far
as practicable.
The figures in the margin indicate full marks.
Attempt all the questions.
1. a) What is object orientation? Explain the difference between structured 7
and object oriented programming approach.
b) What is the role of behavior in OOP? Along with a figure and an 8
example of a CRC card, explain its significance in object oriented
Design.
2. a) What is the difference between message passing and function 8
call? Explain the basic message passing formalism.
b) What is a constructor? Is it mandatory to use constructor in a class? 7
Explain.
3. a) You are given a class Complex and a main program below: 10
class Complex{
void main()
float re, im; {
//To represents complex number eg. 5+i10 Complex C1 (4,5);
Complex C2(3,3);
public: Complex (float x, float y) Complex C3;
{re=x; im=y;} C3=C1+C2;
void show ( ) {cout<<re<<" +i "<<im;} C3.show( );
};
}
What do you mean by operator overloading? How do you overload
the + operator in main program (C3=C1+C2) so that C3 can store a
complex number obtained by adding C1 and C2.
b) What is the role of static data in C++ classes? Give example.
5
4. a) "Inheritance allows us to create a hierarchy of classes." Justify this 7
statement. Discuss the private and public inheritance.
b) Develop a complete program for an institution, which wishes to 8
maintain a database of its staff. The database is divided into number
of classes whose hierarchical relationship is shown in the following
diagram. Specify all the classes and define constructors and functions
to create database and retrieve the individual information as per the
requirements.
STAFF
Staff_ID
Name
LECTURER ADMINISTRATIVE LIBRARIAN
Subject STAFF Shift
Department Post Department
5. a) Distinguish between a subclass and a subtype in light of the principle of 8
substitutability. Support your answer with example.
b) Discuss the role of virtual functions in C++ to cause dynamic
polymorphism. Show with example the how it is different from the
compile time polymorphism. 7
6. a) What is an abstract class? How does it differ from a virtual base class? 2+5
Explain.
b) What is generic programming? How would you convert regular 2+6
classes into templates? Explain with an example.
7. Write short notes on (Any Two): 52
a) Friend function
b) Deferred methods
c) Hybrid inheritance
d) Abstraction