Bit2115:Object Oriented Programming Iii Question Paper
Bit2115:Object Oriented Programming Iii
Course:Bachelor Of Business Information Technology
Institution: Meru University Of Science And Technology question papers
Exam Year:2014
1
INSTRUCTIONS: Answer question one and any other two questions
QUESTION ONE – (30 MARKS)
a) Re write the following while loops as do-while loops. (2 marks)
int count = 0,sum = 0;
while (count ? 10 ){
sum + = count;
count ++;
}
b) Explain the difference between a syntax for defining a class and subclass using examples.
(4 marks)
c) Define and illustrate using an example the following concepts: (4 marks)
(i) For structure
(ii) Switch
d) Differentiate between concepts of class and interfaces using syntax. (4 marks)
e) Given class A extends B extends C:
i. Write a java code snippet for implementing the concept of multiple inheritance.
(3 marks)
ii. Explain the concept of interface (2 marks)
f) Discuss the following:
i) Multithreaded programming (3 marks)
ii) Exception handling (3 marks)
g) Explain the concept and properties of a constructor. (3 marks)
2
h) Describe the concept of Scanner class using an example. (2 marks)
QUESTION TWO (20 MARKS)
a) Discuss in detail the following:
i) Applet life cycle (4 marks)
ii) Java Virtual machine (3 marks)
iii) Types of program errors (3 marks)
b) Write an application that reads three integers and prints their average. (4 marks)
c) What is the output produced by the following statement? Explain. (2 marks)
System.output.println(“He thrusts his fists\n\tagainst” + “the post\nand still insists\n\the
sees the \”ghost\” ”);
d) Write a program that print the following output using for loop. (4 marks)
1
22
333
4444
QUESTION THREE (20 MARKS)
a) Explain the following principles of OOP. (4 marks)
i. Encapsulation
ii. Finalizer methods
iii. Inheritance
iv. polymorphism
b) Using switch statement, write a Java program that determines whether entered letter is a
vowel or not. (4 marks)
c) Explain the relevance of the following keywords as used in Java programming, giving
examples to support your answer. (8 marks)
i. Super
ii. Extends
iii. Instanceof
iv. Throws
d) Write a program that demonstrates the concept of a constructor. (4 marks)
3
QUESTION FOUR (20 MARKS)
a) Differentiate between the following. (8 marks)
i. Aggregation and composition
ii. Method overloading and method overriding
iii. This and new
iv. Try and catch
b) Explain the methods of : (4 marks)
i. Applets life cycle
ii. Thread life cycle
c) Convert the following class diagram into a implemented class in Java. (4 marks)
Glass
Private int maxVolume
Private int currentVolume
Fill (int volume)
Pour (int volume)
int view()
d) Convert the following pseudo code into java code. (4 marks)
If currentVolume equals zero
Then
Print “Empty”
Return errorCode
If currentVolume – volume is less than or equal to zero
Then
volume = CurrentVolume
Set currentVolume to Zero
Return volume
Otherwise
Remove volume from currentVolume
Return volume
QUESTION FIVE (20 MARKS)
a) Create a class called Rectangle that has the following members: (4 marks)
1. Variables : length, width,area,perimeter
2. Methods : calculatearea and calculateperim,printRectangle.
3. Both methods require that you pass length and width.
4
i. Create a class main that instantiate the above class and display the length, width,
area and perimeter.
b) Describe the Thread Life Cycle. (4 marks)
c) Explain the process of writing and compiling Java code. (2 marks)
d) Java is said to be “compiled and interpreted language”. Explain (2 marks)
e) Write a program to illustrate:
i. all escape sequence characters. (4 marks)
ii. try-throw-catch block in exception handling (4 marks)
More Question Papers