Object Oriented Programming Question Paper
Object Oriented Programming
Course:Bachelor Of Science In Information Technology
Institution: Kca University question papers
Exam Year:2011
UNIVERSITY EXAMINATIONS: 2010/2011
SECOND YEAR EXAMINATION FOR THE DEGREE OF BACHELOR OF
SCIENCE IN INFORMATION TECHNOLOGY
BIT 2108: OBJECT ORIENTED PROGRAMMING
DATE: APRIL 2011 TIME: 2 HOURS
INSTRUCTIONS: Answer question ONE and any other TWO questions
QUESTION ONE
a) Describe the qualifiers that an integer can have at a time (4 Marks)
b) What are the characteristics and purpose of escape sequence characters? Give four examples of
such. (6 Marks)
c) The price of one Kg of rice is KES 108.00 and One Kg of Sugar is 120.00. Write a program to
get these values from their user and display the prices as follows
********List of Items********
Item Price
Rice Kes 108.00
Sugar Kes 120.00 (4 Marks)
d) Given the statement
int a=10, b=20, c;
Determine whether each of the following statements are true or false
i. The statement a = + 10 is valid
ii. The expression a + 4/6 * 6/2 evaluates to 11
iii. The expression b + 3/2 * 2/3 evaluates to 20
iv. The expression a + = b; gives the value 30 to a and 20 to b
2
v. The statement ++ a ++; gives the value12 to a
vi. The statement a = 1/b; assigns the value 0.5 to a (6 Marks)
e) What do understand by the term Software Crisis (4 Marks)
f) Describe the following
i) Struct
ii) Union
iii) Class
iv) Object
v) Abstract data type
vi) Inheritance (6 Marks)
QUESTION TWO
a) List FOUR features of monolithic, procedural and structured programming languages
(8 Marks)
b) List FOUR import characteristics of OOP Languages (4 Marks)
c) Write a program to output the following given that the input string is "I LOVE
PROGRAMMING"
I
I L
I LO
I LOV
I LOVE
I LOVE P
I LOVE PR
I LOVE PRO
I LOVE PROG
I LOVE PROGR
I LOVE PROGRA
I LOVE PROGRAM
I LOVE PROGRAMM
I LOVE PROGRAMMI
I LOVE PROGRAMMIN
I LOVE PROGRAMMING (6 Marks)
3
d) what is the function of the following c++ output manipulators
i. setw()
ii. setbase (2 Marks)
QUESTION THREE
a) Write a program to receive item code, quantity, price and calculate the amount. Display the
data in the following format
Sr No Item Code Quantity Price Amount
==== ======= ====== ==== ======
01 0101 10 55.15 551.50
02 0102 20 20.00 400.00
(8 Marks)
b) Outline two rules that must be considered when declaring a member function outside the class
(4 Marks)
c) Outline FOUR characteristics of member functions (4 Marks)
d) Give FOUR reasons why static members are defined outside class declaration (4 Marks)
QUESTION FOUR
a) Write a program to enter a number. Count the total number of digits from 0 to 9 occurring
from 1 to entered number
A sample output will resemble the following
Enter a number: 22151
Number 1 occurs 2 times
Number 2 occurs 2 times
Number 5 occurs 1 times
• Your program has an instance variable num which is an array
• The class has 4 methods
• check to check the number
• show to display the number
• digit to get the number
• ini to initialize the array to zero (12 Marks)
4
b) List the FOUR rules a programmer should follow when declaring static functions (4 Marks)
c) Similar to variables, objects can be passed on to functions. There are THREE methods to pass
an argument to function as given below. List two of them. (4 Marks)
QUESTION FIVE
a) Define the following
i) Polymorphism
ii) Dynamic binding
iii) Static binding
iv) Message passing
v) Constructors
vi) Destructors
vii) Method overloading
viii) Method overriding (16 Marks)
b) Write a program to demonstrate the execution of constructor and destructors. (4 Marks)
More Question Papers
Exams With Marking Schemes