Comp 326:Object Oriented Programming With Java Question Paper
Comp 326:Object Oriented Programming With Java
Course:Bachelor Of Computer Science
Institution: Kabarak University question papers
Exam Year:2013
UNIVERSITY EXAMINATIONS
2012/2013
ACADEMIC YEAR
FOR THE DEGREE OF BACHELOR OF SCIENCE IN
COMPUTER
SCIENCE
COMP 326:OBJECT ORIENTED PROGRAMMING WITH JAVA
DAY:THURSDAY
DATE:11/04/2013
TIME:2.00–4.00 P.M.
STREAM: Y3S2
INSTRUCTIONS:
Attempt
Question ONE
and
Any other TWO
QUESTION ONE (30 marks)
a)
Write a program to accept five units and
print the grade obtained by a student using nested if
..
else statement
(
the user should enter values from the key board)
based on the below criteria
[6 marks]
Average mark
Grade
80
–
100
Honors
60
-
79
First class
50
–
59
Second class
40
-
49
Third class
0
-
39
F
ail
b)
Explain the contents of java Development kit.
[4 marks]
c)
Write a program
to check whether the number in
the array is odd or even
[4marks]
d) State and briefly explain any four common Java exceptions
[4 marks]
e)
W
rite a program to accept
user to input and print the day depending on the input entered by
the user
[ use switch cas]
[ 6 marks]
Page
2
of
3
f)
An electric power distribution company charges its domestic consumers as follows:
Consumption units
rate of charge (Ksh)
0
-
200
0.50 per unit
201
-
400
100 plus 0.65 per unit
401
–
600
230 plus 0.80 per unit
Excess of 400
601 and above
390 plus 1.00 per unit
Excess of 600
Write a java
program that reads customer number and power consumed and prints amount to
be paid by the customer.
[6 marks]
QUESTION TWO (20marks)
a)
Using a suitable diagram exp
lain java virtual machine
[4 marks]
b)
Write a program to accept two numbers from the keyboard and compare the numbers and
print the largest number
[4marks]
c)
Write a program to print the following on the screen
[4 marks]
1
0
11
11
12
12
12
13
13
13
13
14
14
14
14
14
d) Write a program to demonstrate how
two classes can be combined in a single program
[5marks]
e)
Write
do while
loop syntax and explain it
[3 marks]
QUESTION THREE
(20marks)
a)
Write a program to accept array of numbers through the key board and sort the numbers in
the given array
[6 marks]
b)
(i)
What are the rules used when naming classes
[2 marks]
(ii)
Write a syntax us
ed when creating a class
[2 marks]
c)
(i) What is a package
[2 marks]
(ii)
Write example to implement a package
[5 marks]
d)
Explain any three common run time errors
[3 marks]
QUESTION FOUR
(20 marks)
a)
What is interface? Write a program to implement interface
[6 marks]
b)
Explain non numeric data types used in java
[4 marks]
c)
Using a suitable example explain do while statement
[4 marks]
d)
Write a java program to compute sales man commission
as follows
.
< 100 sales
commission =
2 % of sales made
101
-
200 sales
commission = 5 % of sales made
201
-
300 sales
commission = 7 % of sales made
301
-
500 sales
com
mission = 9 % of sales made
> 501 sales
commission = 12 % of sales made
[6marks]
More Question Papers