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

Object Oriented Programming (Bbit 223) (Cisy 210) 3Rd Trimester 2014 Question Paper

Object Oriented Programming (Bbit 223) (Cisy 210) 3Rd Trimester 2014 

Course:Bachelor Of Business Information Technology

Institution: Kenya Methodist University question papers

Exam Year:2014



OBJECT ORIENTED PROGRAMMING (BBIT 223) (CISY 210) 3rd trimester 2014
KENYA METHODIST UNIVERSITY

END OF 3'rd 'TRIMESTER 2014 (FT) EXAMINATION

FACULTY : COMPUTING & INFORMATICS
DEPARTMENT : COMPUTER SCIENCE AND BUSINESS
INFORMATION
UNIT CODE : BBIT 223/CISY 210
UNIT TITLE : OBJECT ORIENTED PROGRAMMING
TIME : 2 HOURS


INSTRUCTIONS

Answer question one and any other two questions

Question One

Briefly explain each of the following terms as used in Java:
(8 marks)
Static method
Dynamic building
Overriding
JVM
Differentiate between
(6 marks)
Object and class
Method and constructor
Abstract method and interface
Write a Java program that demonstrates your understanding of method overriding.
(6 Marks)
Give the importance of the following key words in Java:-
(4 marks)
Super
This
Let S1 be "welcome" and S2 be "welcome." Write code for the following statements:-
(2 Marks)
Assign the first character of S1 to a character variable x.
Scale a new string S3 that converts S1 to lowercase
Identify and fix the errors in the following code:-
(4 marks)
public class test

{

public static void main (string [ ] args)
{
double [100]r;
for (int i = 0; i < r.length ( ); i++)
r (i) = math.random * 100;
}
}



Question Two (15 marks)

Giving the syntax, describe two ways of displaying output in Java.
(6 Marks)
A class called Author is designed to contain:
(9 marks)
Three private instance variables: name (string), email (string) and gender ( char of either ’m’ or ’f’);
One constructor to initialize the name, email and gender with given values;
Public Author (string name, string email, char gender) {…….}
Public getters and setters: getName ( ), getEmail ( ), setEmail ( ) and getGender ( ),
A tostring ( ) method that returns "author_name (gender) at email" e.g "david(m)@somewhere.com"
With the author class, also write a test program called TestAuthor to test the constructor and public methods.



Question Three (15 Marks)

Briefly describe three pillars of object oriented programming.
(6 marks)
Write a method that sums all the numbers in the major diagonal in a matrix of integers using the following header:
Public static double sumMajorDiagonal(double [ ] [ ] m)

With a test program that reads a 4 – by -4 matrix and displays the sum of all its elements on the major diagonal

(9 marks)
Question Four (15 marks)

Design a class named Account that contains:-
(15 marks)
A private int. data field named id for the account (default 0),
A private double data field named balance for the account (default 0)
A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate.
A private Date data field named dataCreated that stores the date when the account was created.
A no args constructor that creates a default account
A constructor that creates an account with the specified id and initial balance.
A method marked getMonthlyInterestRate ( ) that returns the monthly interest rate
A method named getMonthlyInterest( ) that returns the monthly interest
A method named withdraw() that withdraws a specified amount from the account
A method named deposit that deposits a specified amount to the account.
(The method getMonthlyInterest ( ) is to returns monthly interest, not the interest rate. Monthly interest is balance x monthlyInterestRate. MonthlyInterestRate is annualInterestRate/12. Note that annualInterestRate is a percentage, e.g. like 4.5%. you need to divide it by 100)

Write a test program that creates an Account object with an account ID of 1122, a balance of USD 20,000 and annual interest rate of 4.5%. Use the withdraw method to withdraw USD 2500. Use the deposit method to deposit USD 3000 and profit the balance, the monthly interest and the date when this account was created.






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