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

Object Oriented Programming(Bbit 212/ Cisy 111)  Question Paper

Object Oriented Programming(Bbit 212/ Cisy 111)  

Course:Computer Information Systems And Business Information Technology

Institution: Kenya Methodist University question papers

Exam Year:2010



TIME : 2 HOURS
INSTRUCTIONS Answer Question ONE (compulsory) I and any Other TWO Questions

Question 1
a) State the meaning of the following terms as used in object oriented programming (4Marks)
i) Class
ii) Package
iii) Overloading of methods
iv) Class Inheritance
b) State whether true or false
i) A Java exception is an instance of a class derived from Throwable. (1mark)
ii) To create a new thread, your program will either extend Thread class or implement the Runnable interface (1mark)
iii) Java program is interpreted then compiled into byte codes. (1mark)
iv) In Java programming, two variables named Rat and rat are the same. (1mark)
c) Write java syntax for the following
i) Define a constant named credit_hours in java and assign a value 3. (1mark)
ii) Declare a variable that will hold result of finding the square root of 700 (1mark)
iii) Write a method signature for a method which calculates the sum of two integer value and returns the result. (2marks)
d) Provide a brief justification about the following statements in Java (4marks)
i) Java is platform independent
ii) Java is safe.
iii) Java is Garbage Collected.
iv) Java is multithreading
e) Write a java program which defines a method that calculates the maximum of any given two values and displays the result on a message dialog. (6marks)
f) Give two differences between interfaces and abstract classes. (4marks)
e) Define the term abstract data type (ADT) (2marks)
f) Define the term Java Applet. (2marks)

Question 2
a) Show how the following is accomplished in Java. You can illustrate with an example. (9marks)
i) Object instantiation
ii) Message passing
iii) Interface implementation
b) Constructor is special kind of method. Explain three differences with other methods. (3marks)
c) Discuss how the concept of encapsulation enhances good programming practice in object oriented systems (3marks)

Question 3
a) Create a class called student that has the following members: (9marks)
i) An instance integer variable called my_age.
ii) An instance character variable called my_grade.
iii) An instance integer variable called your_age.
iv) An overloaded constructor that initializes the my_age and my_grade and the other constructor initialize your_age instance variables.
v) A method called my_details that print out the content of my_age and my_grade
vi) variables and another method called your_details that return the content of your_age variable.
b) Write declarations or Java statements to accomplish each of the following tasks:
i) Display a dialog asking the user to enter an integer and assign to String variable value
ii) Convert the String in part (i) to an integer, and store the converted value in the integer variable age.
iii) Print “This is real good” on two lines in the command window; the first line should end with real. Use only one print or println statement. (6Marks)

Question 4
a) State any two limitations of using an array (2Marks)
b) Create a class that creates a 5-element array of Strings called Fruit at class level but do not initialize it with any values. Create a method called a method. In a method, initialize the first four elements with the names of fruit. Create another method called modify and change the contents of the first element of the Fruit array to contain the string "bicycle". Within the modify method create a for loop that prints out every element of the Fruit array. (6Marks)
c) i) Explain the term exception and state the benefit of exception handling in computer programs. (3Marks)
ii) Explain the uses of each of the following clauses used in handling exceptions in Java:
(1) Try
(2) Catch (4Marks)

Question 5
a) In multithreading system threads exhibits several states. Explain five states of threads in Java. (5Marks)
b) Write a simple program showing inheritance with a parent class bicycle and a child class mountain bike (5Marks)
c) Write an application that accepts a person’s weight and displays the number of calories the person needs in one day. A person needs 42 calories per kilogram of body weight, so the formula expressed in Java would be: calories=bodyWeigh*42. (5Marks)






More Question Papers


Popular Exams


Mid Term Exams

End Term 1 Exams

End Term 3 Exams

Opener Exams

Full Set Exams



Return to Question Papers