Ics 2104 Object Oriented Programming I
Ics 2104 Object Oriented Programming I
W1-2-60-1-6
JOMO KENYATTA UNIVERSITY
OF
AGRICULTURE AND TECHNOLOGY
University Examinations 2014/2015
SECOND YEAR FIRST SEMESTER EXAMINATION FOR THE DEGREE
OF BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY
ICS 2104: OBJECT ORIENTED PROGRAMMING I
DATE: AUGUST 2015 TIME: 2 HOURS
INSTRUCTIONS: ANSWER QUESTION ONE (COMPULSORY) AND ANY OTHER
TWO QUESTIONS
a) State the main different between the following terms as used in object oriented
programming. (8 Marks)
b) Using switch statement write a C++ program to display the day depending ion the choice
entered by the user from the key board i.e 1 15 Monday, 2 1 5 Tuesday, 3
Thursday: …….. 7 1 5 Sunday (5 Marks)
c) What is an array? With the help of a code show how an array is declared in C++.
(3
Marks)
d) Explain three (3) reasons as to why object oriented programming is gaining more
popularity as compared to procedural programming. (3 Marks)
(i) a>b&&b>.c
(ii) = = b| |a>=c
g) All variables listed in any program should be associated with their respective data types.
Explain any four data types used in C++. (4 Marks)
b) Write a statement to declare and instantiate an array to hold marks obtained by students
in different subjects in a class. Assume that the class can hold up to 60 students and there
are 8 subjects. (4 Marks)
Char g;
int marks;
if (marks > . 69)
g = ‘A’
else if (if (marks > 59)
g = ‘B’
else if (if (marks > 49)
g = ‘C’
else if (marks > 39)
g = ‘D’
else
g = ‘E’
c) Show how the same piece of program can be implemented using the switch statement.
(5
Marks)
c) Write a program that declares a class called Rectangle that contains two data members for
length and width. The class should demonstrate the use of functions that are defined
within the class and those that are declared within the class are defined externally. The
program should show the definition of both types of functions. (6 Marks)
d) Give any six (6) rules for a valid constructor in C++. (4 Marks)
(i) Recursivity
b) At JKUAT, the admission criteria require that an applicant must get a grade equivalent to
60 marks. To enroll for BSc in Computer Science, an applicant must have minimum of
60 marks in group one subject: Physics, Mathematics and English. However, a
candidate with 65 marks in group 2 subjects: English, Physics and Chemistry also
qualified for admission. Write an object oriented program that accepts input from an
applicant and advises whether one qualifies for admission or not.
Required:
The two groups must be implemented as functions: group 1 and group 2 inside your
class.
The program should have menu with 1 and 2 such that if a user enters 10/he has selected
group 1 subjects; and 2 for selecting group 2 subjects. (10 Marks)
c) Discuss the following object oriented concept; use a simple example in each case:
b) Discuss the main five (5) access specifiers in a class declaration. (5 Marks)
c) Using the concepts of filling, write a C++ program for computing the largest of three
numbers. (5 Marks)
d) Use the switch statement to write a program that accepts the grade of a certain type of
coffee and then outputs an appropriate message based on the following table.
Declare the appropriate variables. (5 Marks)
Grade Message
A Export quality
B Local market
C Goal for blending
All other Rejected