MERU UNIVERSITY OF SCIENCE AND TECHNOLOGY
P.O. Box 972-60200 – Meru-Kenya.
Tel: +254(0) 799 529 958, +254(0) 799 529 959, + 254 (0) 712 524 293,
Website: info@must.ac.ke Email: info@must.ac.ke
University Examinations 2017/2018
THIRD YEAR SECOND SEMESTER EXAMINATION FOR THE DEGREE OF
BACHELOR OF INFORMATION SCIENCE
SECOND YEAR SECOND SEMESTER BACHELOR OF BUSINESS INFORMATION
TECHNOLOGY
CIT 3203: OBJECT ORIENTED PROGRAMMING II
DATE: SEPTEMBER 2018 TIME: 2 HOURS
INSTRUCTIONS: Answer question one and any other two questions
QUESTION ONE (30 MARKS)
a) Briefly describe the purpose of the following UML diagrams (4 marks)
i. Class diagram
ii. Sequence diagram
b) Use an example to illustrate the principle of encapsulation as used in Object oriented
programming (4 marks)
c) Differentiate between the following variable types (4 marks)
i. Instance variable and class variable
ii. Local variable and global variable
d) Use an example to differentiate between public and private attribute as such in object
oriented programming (4 marks)
e) Write a Java program to sort 6 numbers in ascending order using an in-built array
methods (4 marks)
Meru University of Science & Technology is ISO 9001:2015 Certified
Foundation of Innovations Page 1
f) Write a Java program that computes the area and circumference of a circle, your
program should have a class called circle. That should have a single data member for
the radius and constructor that receives a parameter for the data member. The class
should contain methods that calculate and return the area and circumference
respectively of the circle object (6 marks)
g) Write an object oriented program to create a class employee with employee number,
first name, second name, hours worked and rate per hour attributes and 2 methods to
calculate gross pay and tax charged at 10% (4 marks)
QUESTION TWO (20MARKS)
a) Use an example to illustrate how inheritance is applied in Java programming giving an
example (4 marks)
b) Write a Object Oriented Program to create an object cube with length, height and
width properties, a method to calculate the cube volume, create an instance for the
object and use the object instance to calculate the volume of a cube with length 20cm,
height 15cm and width 10cm then display the result (6 marks)
c) Write a Java program to perform the following using the Math method (4 marks)
i. Display the larger number between 2 numbers entered
ii. Calculate the power of the first number based on the second number
d) Write a program to declare a class person that has the attributes name, gender, county
and phone number and behaviour getdata and displaydata. The program should also
create two classes, students and employee that inherit from the class person and
additionally introduce their own attributes and behaviours. The subclass introduce at
least two attributes and a method (6 marks)
QUESTION THREE (20 MARKS)
a) Write a program to enter a string value the display the string length (2 marks)
b) Write object oriented program to create an object book with book number, title, author
name and quantity and a method to get the available quantity=total quantity-purchased
quantity. Use inheritance to create magazine object that will inherit all attributes of
book title apart from author title (6 marks)
Meru University of Science & Technology is ISO 9001:2015 Certified
Foundation of Innovations Page 2
c) Write a program to enter a number then use two separate methods to calculate the:
i. Square of the number (3 marks)
ii. Cube of the number (3 marks)
d) What is the purpose of ‘this’ keyword used in Java programming (2 marks)
e) Distinguish between a service and an object (4 marks)
QUESTION FOUR (20 MARKS)
a) With an aid of examples discuss the following object oriented programming concepts
(6 marks)
i. Constructor
ii. Method
iii. Exception
b) i. Write a Java code to create class named student with student name, course, and
department properties (4 marks)
ii. Create another class called exam that inherits properties of student class created in
3b,i) above and has additional math, science and English marks properties and
methods to calculate total and average marks (4 marks)
iii.Write a program that uses exam instance to calculate student marks and display the
result (4 marks)
c) briefly explain the purpose of the following Java classes (2 marks)
i. JFrame
ii. JLabel
QUESTION FIVE (20 MARKS)
a) Given the structure below show how inheritance can be implemented through the use
of class definition, variables and constructors (6 marks)
University _member (ID_NO,birth_date)
Student (ID_NO,degree_course,year, Lecturer (ID_NO, degree_course,
birth_date year, birth_date)
Meru University of Science & Technology is ISO 9001:2015 Certified
Foundation of Innovations Page 3
b) Use an example in each case below to illustrate the following OOP concepts below
(4 marks)
i. Polymorphism
ii. Encapsulation
c) Write a Java code to create an object product with product name, price and quantity
properties, a method to calculate the total price, create an instance for the object and
use the object instance to calculate the total price and display the result (6 marks)
d) What are the requirements for creating Service Oriented Architecture? (4 marks)
Meru University of Science & Technology is ISO 9001:2015 Certified
Foundation of Innovations Page 4