Object Oriented Programming Exam - CP 215
THE UNIVERSITY OF DODOMA
COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION
SCHOOL OF INFORMATICS
UNDERGRADUATE UNIVERSITY EXAMINATIONS
FIRST SEMESTER 2014/2015
CS 213: OBJECT ORIENTED PROGRAMMING IN JAVA
Date: 11th February, 2015
Time Allocated: 3 Hours
Instructions:
- This question paper consists of six questions.
- Answer Question One and any other four questions making a total of five questions answered.
- All University of Dodoma examination regulations apply.
Question One
i. Differentiate between a class and an object. (4 Marks)
ii. Differentiate between an argument and a parameter. (4 Marks)
iii. Write java class that has one instance variable, a programmer defined constructor which initializes that instance variable of the class and one method that accepts an integer value. Write another java class that instantiates an object of the class that was created and calls the method defined in the class. Use comments to indicate a parameter and an argument. (12 Marks)
Question Two
i. Differentiate between inheritance and polymorphism. (4 Marks)
ii. Differentiate between method overriding and method overloading as used in polymorphism. (4 Marks)
iii. Write java classes that illustrate concepts defined in part (ii) above. (12 Marks)
Question Three
i. Differentiate between an applet and an applet container. (4 Marks)
ii. Describe the applet lifecycle. (8 Marks)
iii. Write an applet program that displays “CIVE 2015” at the CENTRE of the applet container and size of the container should be 350 pixels wide and 400 pixels tall. (8 Marks)
Question Four
i. Differentiate between AWT and SWING. (4 Marks)
ii. Write a java program that accepts two integers from the user and outputs their sum. The program is a graphical user interface using the javax.swing package. (16 Marks)
Question Five
i. Differentiate between a one-dimensional and a multidimensional array. (6 Marks)
ii. Write a java class that creates a two dimensional array (three rows and four columns) of integer values. Use a for-loop and a Scanner utility class as means of data input. Again use a for-loop to output these values to the screen, each row should be in its own line. Exception handling is not required. (14 Marks)
Question Six
i. Differentiate between exception and exception handling. (4 Marks)
ii. State three scenarios in which an exception can occur. (3 Marks)
iii. Write a java program using try-catch to illustrate exception handling in which a user tries to access an array element that does not exist. (13 Marks)
Question Seven
i. Distinguish among local, instance and class variables. (6 Marks)
ii. Write java program(s) that illustrate declaration and usage of instance variables, instance methods, class variables and class methods. (14 Marks)
END OF EXAMINATION PAPER