August
1999 QUESTION 2 Total Marks: 20 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
(a) | One of the key features of an Object Oriented programming language is the ability to design abstract data types. Explain what is meant by an abstract data type. | [3]
|
An abstract data type
is:
|
||
(b) | A Java class consists of member variables and
methods. Explain, with reference to your definition of an abstract data types, what is
meant by the terms (i) member variable (ii) method |
[1] [1] |
(i) Member variables
are the data held in the class. (ii) Methods are the operations, or functions, which operate on them.
|
||
(c) | List 3 primitive data types in the Java programming language. | [3] |
Any 3 of :
|
||
(d) | A computer screen is displayed by coloring in
a set of pixels (picture elements). Each pixel can be characterized by an x coordinate and
a y coordinate. (i) Define a class, called Pixel, which represents this idea. (ii) The resolution of a VGA screen is 256 pixels by 256 pixels, giving a total of 65536 pixels. Define a class, VGA_Screen, which contains an array of pixels called MyScreen which is sufficiently large enough to represent the VGA screen. (iii) Write a main method, which is a member of your VGA_Screen class. Using two nested for loops, the method should initializes the values of the x and y values of each pixel in the array MyScreen, such that each pixel is given a unique coordinate on the screen. |
[3] [3]
|
(i) a sample
definition of Point follows: public
class Point{
|
||
(ii) A sample
definition of VGA_Screen follows : public class VGA_Screen {
|
||
(iii) A sample
definition of the main function follows: public static void main ( ){
|