BIT2204A  JAVA PROGRAMMING .

UNIVERSITY EXAMINATIONS: 2018/2019
EXAMINATION FOR BACHELOR OF SCIENCE IN INFORMATION
TECHNOLOGY/ BUSINESS INFORMATION TECHNOLOGY
BIT2204A JAVA PROGRAMMING
DISTANCE LEARNING
DATE: AUGUST, 2019 TIME: 2 HOURS
INSTRUCTIONS: Answer Question One and Any Other Two Questions

QUESTION ONE
(a) Briefly explain the meaning of the following terms and write Java code that demonstrates its
usage. (6 Marks)
(i) Variable
(ii) Concatenation of data items
(iii) Assignment of a value
(b) Write a Java class that calculate the sum and the product of two numbers. (4 Marks)
(c) A number is called prime number if it is divisible by either itself or 1. Write a program in
Java to find out if a number is prime in Java? (input 7: output true , input 9 : output false)
(3 Marks)
(d) Write a java program the implements the following flow chart (4 Marks)


(e) Write a Java Program the prints the following output using a repetition structure (4 Marks)
*
***
*****
***
*
(f) Write a java class that implements the following pseudocode (5 Marks)
(g) Write a java class that implements the following ATM pseudocode (4 Marks)


QUESTION TWO
(a). State and explain three repetition structures as used in java programming. Write a sample
java code to illustrate each structure.
(6 Marks)
(b). Describe the characteristics of the following methods and write a sample java for each case
(4 Marks)
i. Constructor
ii. Static method
(c). Describe the difference between getter method and a setter method. Write a sample code for
each case (4 Marks).
(d). Write a Java class that calculate the area and perimeter of a rectangle. The class should
contain at least two methods (6 Marks)
1 Start
2. Read number N,
3. Set remainder as N modulus 2,
4. If remainder is equal to 0 then number N is even, else number N is odd
5. Print output.
6. Stop
QUESTION THREE
(e) Write a java class that prompt the user to enter name, age, course name and outputs the
information entered (4 Marks)
(b) An exercise book costs Kshs 20 and it is been sold at a discount of 12%. Write a java class
that calculates discount price of the pen and print the cost of buying two exercise books.
(5 Marks)

(c) Briefly describe the meaning of the following concepts as used in Java programming. Write a
sample code to demonstrate each concept
(i) Implementing an interface (2 Marks)
(ii) Class inheritance (2 Marks)
(d) Describe the difference between object and a class. Write a sample java code to illustrate
implementation of each concept (4 Marks)
(e) Describe three features of Java programming language (3 Marks)
QUESTION FOUR
(a) Write a Java class that calculate the area and circumference of a circle. The class should
have at least two methods (6 Marks)
(b) Peter Otieno is an employee in XYZ Company. He works 40hrs per week and the hourly
pay rate is kshs 1000. Given that tax withholding rate is 9%, write a java class that calculate net
pay for peter per week. The output should be formatted as follows: (6 Marks)
Employees Full Name:
Numbers of Hours worked in a week:
Hourly Pay Rate:
Gross Pay
Tax withholding rate:
Net Pay:
(c) Write a java program called CheckPassFail which prints “PASS” if the int variable “mark”
is more than or equal to 50; or prints “FAIL” otherwise. The program shall always print
“DONE” before exiting. (4 Marks)
(d) Describe the purposes of the following qualifiers as used in Java programming
(4 Marks)
(i) Public
(ii) Private
(iii) Protected
(v) Static
QUESTION FIVE
(a) Write a program called CheckOddEven which prints “Odd Number” if the int variable
“number” is odd, or “Even Number” otherwise. The program shall always print “bye!” before
exiting. (4 Marks)
(b) Write a program called PrintDayInWord which prints “Sunday”, “Monday”, …
“Saturday” if the int variable “dayNumber” is 0, 1, …, 6, respectively. Otherwise, it shall
print “Not a valid day”. (5 Marks)
(c)Write a program called SumAverageRunningInt to produce the sum of 1, 2, 3, …, to 100.
Store 1 and 100 in variables lowerbound and upperbound, so that we can change their values
easily. Also compute and display the average. (5 Marks)
The output shall look like:
The sum of 1 to 100 is 5050
The average is 50.5
(d) Give two numbers a=25 and b=39, Write a Java program to compare two numbers and
print results (4 Marks)
(e) Describe the difference between static and non-static methods as used in java
programming (2 Marks)

(Visited 214 times, 1 visits today)
Share this:

Written by