SPC 2206 Object Oriented Programming II YEAR II SEM II
SPC 2206 Object Oriented Programming II YEAR II SEM II
f) Write JAVA snippet code to demonstrate the use of THIS key word [4Marks]
g) Describe any four elements of Graphical User Interface Programming in Java. [4 Marks]
h) Describe three benefits of Swing over AWT as applied in java programming [3 Marks]
Page 1 of 3
SECTION TWO (40 Marks)
Attempt TWO questions from this section
a) Outline two differences between methods and constructors as used in Java, [4 Marks]
b) Using super class ‘House’, base class ‘Bedroom’ and a method called ‘Sitroom’, Write a
code snippet to demonstrate runtime polymorphism in Java. [8 Marks]
b) Write a Java code to output the following using For Loop control structure [6 Marks]
*
**
***
****
*****
c) The following is a program that demonstrate one of the concepts of object-oriented
programming
1. import java.io.*;
2. interface Animal {
3. void eat();
4. }
5. interface Mammal {
6. void drink();
7. }
8. class Dog implements Animal, Mammal {
9. public void eat() { System.out.println("Eating"); }
10. public void drink() { System.out.println("Drinking"); }
11. void bark() { System.out.println("Barking"); }
12. }
13. class question {
14. public static void main(String[] args)
15. {
16. Dog d = new Dog();
17. d.eat();
18. d.drink();
19. d.bark();
20. }
Page 2 of 3
21. }
a) write a program using an interface to calculate area and perimeter of a circle 7 Marks
b) Explain three drawbacks of Garbage Collection in java programming [6 Marks]
c) Describe three features of Constructors in Java [3 Marks]
d) Explain two advantages of object cloning in java [4 Marks]
b) Write a Java Graphical User Interface program that can produce the following interface
using Java swing components . [8 Marks]
Page 3 of 3