DBIT 404 OBJECT ORIENTED PROGRAMMING.

UNIVERSITY EXAMINATIONS: 2015/2016
EXAMINATION FOR THE DIPLOMA IN BUSINESS INFORMATION
TECHNOLOGY
DBIT404 OBJECT ORIENTED PROGRAMMING
DATE: AUGUST 2016 TIME: 1½HOURS
INSTRUCTIONS: Answer Any THREE Questions.

QUESTION ONE
(a) Explain the meaning of following object oriented programming concepts.
i. Object
ii. Class
iii. Polymorphism
iv. Abstraction
v. Encapsulation (10 Marks)
(b) Describe the following permissions as used in class inheritance.
i. Public (2 Marks)
ii. Private and (2 Marks)
iii. Protected (2 Marks)
(c) Discuss inheritance as used in application development. (2 Marks)
(d) Explain the role of a constructor function in an object oriented program. (2 Marks)
QUESTION TWO
(a) Debug the following C++ program. (10 Marks)
#include “iostream”
Main[]
{ integer num, square; /declaration of variables
cout<<” Enter a number “;
cin>num;
2
Square = num*num;

cout<<“The number is squared is <<square;}
(b) Create a class called SalesClass with relevant attributes and methods to read sales done by a
salesman and display the commission he/she should be paid Implement the class using
an object that performs the above operations.
Commission = 3% of (Sales-100000) (10 Marks)
QUESTION THREE
(a) Write a single C++ statement for each of the following:
(i) cin object to read two integer variables, a and b using a single statement.
(ii) Scope resolution operator (::) to define a method titled void readEmployee( )
which belongs to a class Employee
(iii) cout object to output three variables x, y and z followed by new line
(iv) Test if a variable newSalary s equal or greater than oldSalary and if true display
the message “New salary is higher”
(v) Derive a class mobilePhone from another class Phone
(vi) Decrement the variable counter by 1 then print its value.
(12 Marks)
(b) Describe four basic data types in C++ (8 Marks)
QUESTION FOUR
(a) List five comparison operators used in C++ and state their meaning. (5 Marks)
(b) Identify errors in the following program. (8 Marks)
#include<iostream.h>
class car
{ private
character colour[10];
int wheelsNumber;
3
public:
void readcar();
void showcar() };
void car::readcar()
{
cout<< “Enter colour of car “;
cin>colour;
cout<< “Enter number of wheels “;
cin>>wheels Number;
}

void car:showcar()
{
cout<< “The car is painted “<<colour;
cout<< “The number of wheels is “<<wheelsNumber;
}

main()
{
car testCar;
testCar.Readcar();
testCar.showcar();
}
(c) Give the syntax of an “if” statement when two alternative outcomes are involved
(3 Marks)
(d) Using examples, differentiate between an attribute and a method. (4 Marks)
QUESTION FIVE
(a) Using examples, briefly discuss the following program components:
(i) Header file
(ii) Comment
(iii) Keyword
(iv) Output statement
(v) Input statement
(10 Marks)
(b) Explain the role of the main() function in a C++ program. (2 Marks)
(c) “C++ language is case sensitive”. Explain this statement. (2 Marks)
(d) Discuss two types of loops used in C++. (4 Marks)
(e) Define the term “array” as used in a C++ program and give the syntax of declaring an array.
(2 Marks)

(Visited 118 times, 1 visits today)
Share this:

Written by