August 1999
JP219 : JAVA PROGRAMMING

QUESTION 2

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

(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]

 

(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]

(c) List 3 primitive data types in the Java programming language.

 

[3]
(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]



[6]