Get premium membership and access revision papers, questions with answers as well as video lessons.

Bit 204: Object Oriented Programming Question Paper

Bit 204: Object Oriented Programming 

Course:Bachelor Of Information Technology

Institution: South Eastern Kenya University question papers

Exam Year:2012




SOUTH EASTERN UNIVERSITY COLLEGE
(A CONSTITUENT COLLEGE OF THE UNIVERSITY OF NAIROBI)

UNIVERSITY EXAMINATIONS 2012/2013

SECOND YEAR FIRST SEMESTER EXAMINATION FOR THE DEGREE OF BACHELOR OF INFORMATION TECHNOLOGY

BIT 204: OBJECT ORIENTED PROGRAMMING


DATE: 8 /8/2012 TIME: (2 HOURS)

INSTRUCTIONS TO CANDIDATES
a) Answer ALL questions from section A(Compulsory)
b) Answer ANY THREE questions from section B




SECTION A (31 Marks) - Compulsory
Question One
a) State three differences between Object Oriented Programming and Procedural
Programming. (3 marks)
b) Distinguish between the following terms: (4 marks)
i) Class and object.
ii) Pass-by-value and pass-by-reference.
c) i) Analyze the code fragment shown below determining the output generated after its
execution. (2 marks)
int found = 0, count = 5;
if (!found || count == 0)
cout << "Hatari" << endl;
cout << "count = " << count << endl;
ii) Justify your answer in (i) above (1 mark)

d) In the figure below identify the visual C++ IDE elements labeled A to C analyzing the
function(s) of each. (6 marks)


















Question Two
a) Explain the following OOP concepts: (4 marks)
i) Data Abstraction
ii) Encapsulation
iii) Inheritance
iv) Polymorphism
b) Study the program shown below and answer the question that follow: (6 marks)

1 class numbaz{
2 private:
3 int num1, num2;
4 } numObj_A, numObj_B;
5 int findSum( );
6 #include
7 void main( ){
8 numbaz numObj_C;
9 }


Explain the purpose of each of the following lines of the code:
i) Line 1
ii) Line 2
iii) Line 4
iv) Line 5
v) Line 6
vi) Line 8

c) Given that matrices A, B and C such that;


A = B = and C = A + B



Write a C++ program implementing a nested for loop within which the user is prompted for corresponding values of matrices A and B, calculate and display the contents of matrix C. (5 marks)

SECTION B (39 Marks)

Question Three
a) Outline three characteristics of an object. (3 marks)
b) Explain four advantages of object-oriented paradigm. (4 marks)
c) Identify the syntax errors in the following program by rewriting its correct version. (6 marks)
#include [iostream.h]
Class payItNow {
int Charge;
PUBLIC:
void Raise( ){cin>>Charge;}
void Show{cout<}
void Main( ){
PayItNow P;
P.Raise( );
Show( );
}


Question Four
a) With the aid of diagrams describe each of the following: (4 marks)
i) Multiple inheritance
ii) Multilevel inheritance
b) Study the program below and answer the questions that follow.

class CUSTOMER {
int Cust_no; char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
} obC1;

class SALESMAN {
private:
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
} obS1, obS2;

class SHOP : private CUSTOMER , public SALESMAN {
char Voucher_No[10];
char Sales_Date[8];

public:
SHOP();
void Sales_Entry();
void Sales_Detail();
} obSH1;

I) State the type of inheritance implemented by the above program. (1 mark)
II) Identify the base-class(es) and the derived class(es) of:
i) Class CUSTOMER (1 mark)
ii) Class SHOP (2 marks)

III) State the names of all:
i) Member functions directly accessible by objects of class SALESMAN. (1 mark)
ii) Functions directly accessible and manipulated by objects of class SHOP. (2 marks)

IV) Identify four objects that have been created during the class definitions. (2 marks)

Question Five
a) i) Determine the output generated by the following code fragment giving a reason.
(2 marks)
int n = 5;
if (n = 0)
cout << "n is zero" << ".\n";
else
cout << "n is not zero" << ".\n";
cout << "The square of n is " << n * n << "\n";

ii) Identify the error in the code fragment in (i) above. (1 mark)
b) Study the code fragment shown below and answer the questions that follow.
int n, k = 5;
n = (100 % k ? k + 1 : k - 1);
cout << "n = " << n << " k = " << k << endl;
i) Construct a flowchart to depict the logic of the code fragment. (3 marks)

ii) Determine the output generated when the following code fragment is executed.(2 marks)

c) Write a C++ program to prompt the user to enter an integer.The program should test whether the integer is a prime number or not, it should display the number followed by the messages “Prime” or “Not prime” accordingly. Use a for loop structure. (5 marks)

Question Six
a) State three differences between function overloading and function overriding (3 marks)

b) Write the code of a class named EXAM with following description. (10 marks)
Private Members;
1. exmCode of type string, 6 characters.
2. xmDescription of type string, 40 characters.
3. noCandidate of type integer.
4. centersReqd (number of centers required) of type integer.
5. A member function CALCNTR( ) to calculate and return the number of centers as (noCandidates/100+1).

Public Members;
1. A function SCHEDULE( ) to allow user to enter values for exmCode, xmDescription, noCandidate and call function CALCNTR( ) to calculate the number of centers.
2. A function DISPXM( ) to allow user to view the content of all the member data.
(The functions should be prototyped within the class and their definitions placed outside the class)

Question Seven
a) Define the following terms: (3 marks)
i) Constructor function
ii) Destructor function
iii) Friend function

b) Study the program below and answer the questions that follow.

class B {
private:
int x, wx;
void Fxwx (void);
public:
int y;
void Fy (void);
void showData (void);
void getData (void);
protected:
int z;
void Fz (void);
};

I) Determine the population of :
i) member data of class B (1/2 mark)
ii) member functions of class B (1/2 mark)
II) Write in its simplest form the:
i) default constructor to the class B (1 mark)
ii) default destructor to the class B (1 mark)
III) Give the header of a class, class DD : B { …….}; complete the table below.(3 marks)


Inherited member data or function Explanation of status of inherited member data/function in class DD
i) Fxwx( )
ii) y
iii) getData( )

IV) Construct the header of a :
i) Class named D1 that inherits class B in an inheritance mode that maintains the status of ALL the inherited members as they are in the base class B.
(1 mark)
ii) Class named D2 that inherits class B in an inheritance mode that causes the status of public members of the class B to acquire a different status in class D2 and the protected members of class B to retain the same status in both class B and D2. (1 mark)

V) Declare a function main( ) that accomplish the following tasks:
Instantiates the class D2 with objects ob1 and ob2; assigns the value 24 to the instance variable y of the object ob1; and invokes the function showData( ) relative to the object ob1. (2 marks)

END






More Question Papers


Popular Exams



Return to Question Papers