0% found this document useful (0 votes)
171 views

Ics 2201 Object Oriented Programming Ii

This document contains instructions for an examination on Object Oriented Programming II. It lists 5 questions, with subquestions under each main question. Question 1 asks about differences between objects and classes, encapsulation and data abstraction, access control modifiers, reasons for OOP's increasing popularity, a Java switch structure, primitive data types, constructors, and writing a program to calculate values of variables a and b. Question 2 asks about method overriding vs overloading and characteristics of Java. Question 3 asks about differences between Java applications and applets, using arrays, a switch statement program, and differences between static and instance variables. Questions 4 and 5 contain additional subquestions on programming concepts like loops, methods, packages, data types, and compound

Uploaded by

naomi.amadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views

Ics 2201 Object Oriented Programming Ii

This document contains instructions for an examination on Object Oriented Programming II. It lists 5 questions, with subquestions under each main question. Question 1 asks about differences between objects and classes, encapsulation and data abstraction, access control modifiers, reasons for OOP's increasing popularity, a Java switch structure, primitive data types, constructors, and writing a program to calculate values of variables a and b. Question 2 asks about method overriding vs overloading and characteristics of Java. Question 3 asks about differences between Java applications and applets, using arrays, a switch statement program, and differences between static and instance variables. Questions 4 and 5 contain additional subquestions on programming concepts like loops, methods, packages, data types, and compound

Uploaded by

naomi.amadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

W1-2-60-1-6

JOMO KENYATTA UNIVERSITY


OF
AGRICULTURE AND TECHNOLOGY

University Examinations 2014/2015

YEAR II SEMESTER II EXAMINATION FOR THE DEGREE OF BACHELOR OF


SCIENCE IN INFORMATION TECHNOLOGY/ BACHELOR OF BUSINESS
INFORMATION TECHNOLOGY

ICS 2201: OBJECT ORIENTED PROGRAMMING II

DATE: APRIL 2015 TIME: 2 HOURS

INSTRUCTIONS: ANSWER QUESTION ONE (COMPULSORY) AND


ANY OTHER TWO QUESTIONS.
______________________________________________________________________

QUESTION ONE (30 MARKS)

(a) State the main difference between the following terms as used in Object
Oriented Programming.

i) Object and classes

ii) Encapsulation and data abstraction (4 marks)

(b) List and explain any three main Access Control Modifiers in a class
declaration that are used in Java Programming. (6 marks)

(c) Explain three reasons as to why object oriented programming is gaining


more popularity as compared to procedural programming. (3 marks)

(d) The value of a variable y depends on the value of variable x as shown


below:

x y
1 0.1
2 0.2
Other value 0

1
Write down java switch structure for the problem. (3 marks)

(e) All variables used in any program should be associated with their
respective data types. Explain any four primitive data types used in java.

(f) Describe a constructor and explain four rules for a valid constructor in
java programming. (4 marks)

(g) Explain the parts of the main method “Public static void main
(Strings [I args]” (4 marks)
6
(h) Given a = x5 + y 3 write a program that allows user to enter the values of x
and y and give output of a and b. (4 marks)
QUESTION TWO (20 MARKS)

(a) Explain the difference between method overriding and method


overloading. (4 marks)

(b) State and explain four characteristics of Java programming which give
advantage over other high level programming languages. (4 marks)

(c) Design and write a Java program that allow the user to enter the mass (in
kg) and Height (in metres) the program then compute the body mass index
(BMI) of patient in hospital and output appropriate interpretation using the
following table.

NB: The formula is:


Mass( Kg)
( Height(m )2
BMI = (7 marks)

BMI range – kg/m2 Interpretation


Less than 15 Very severely underweight
From 15.0 but less than 16.0 Severely underweight
From 16.0 but less than 18.6 Underweight
From 18.5 but less than 25.0 Normal (Healthy weight)
From 25.0 but less than 30.0 Overweight
Over 30 Obese

(d) i) Explain the term jave development tool kit (jdk) (2 marks)

ii) Explain the characteristics of objects in java programming.(3 marks)

QUESTION THREE (20 MARKS)

(a) With examples state the major difference between Java stand alone
applications and Java applets. (4 marks)

2
(b) Define the term array and write object oriented program that uses an array
to store four names and display the names. (4 marks)

(c) Using switch statement write a java program to display the day depending
on the choice entered by the user form the key board i.e. is Monday, 2 is
Tuesday, 3 is Wednesday…..7 is Sunday. (6 marks)

(d) Given that a = 20, b = 5, c = 9. What is the value of the following


expressions:

i) a>b&b>c

ii) a = = b 11 a > = c (2 marks)

(e) With example of java program explain the difference between static and
instance variables. (4 marks)

QUESTION FOUR (20 MARKS)

(a) Give two differences between While…and do… While (2 marks)

i) Using while loop, write a program to output all numbers divisible by


2 between 1 and 50. Make use of the modulus operator.(4 marks)

Re-write the above program using do while loop. (3 marks)

(b) Write a java program which allows the user to input three integers in then
output the maximum of the integers. (5 marks)

(c) Discuss the following object oriented concept, use a simple


example in each case.

i) Encapsulation

ii) Polymorphism

iii) Function overloading (6 marks)

QUESTION FIVE (20 MARKS)

(a) Explain the different steps used in developing a java application.(6 marks)

(b) Java Library classes are organized into packages. Explain the use of the
following classes:

i) java.util

ii) java.awt

3
iii) javax.swing (3 marks)

(c) Write a Java program that does the following:

i) Prompt the user to input five decimal places and convert each decimal
number to the nearest integer

ii) Prints the sum and average of the five integers (5 marks)

(d) Write a Java program that computes compound interest compounded


yearly) using the following formula A = P (1 + r) n P is original amount
invested , r is annual interest n is number of years. A is amount at end of
nth year. The user enters, P , r and n and results for various years are
displayed on the screen. (6 marks)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy