August 2000
JP219 : JAVA PROGRAMMING

QUESTION 2

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

(a) Explain what is meant by a Java applet, and how it differs from a Java
application. [3 marks]

(b) Declare a class Scribble, such that it can be run as an applet. Your class should include the protected int members X1 and Y1. [3 marks]

(c) A Graphics object is the simplest way to do drawing in Java. It contains the method drawString, which takes three parameters, a string, an x co-ordinate and a y coordinate.
Write a method for your Scribble class which initialises the applet, and causes the string “Hello World” to be written at coordinates (20, 30). [4 marks]

(d) Write the HTML needed for your Scribble applet to be displayed in a viewer, with dimensions 100 x 100. [3 marks]

(e) Give the import statements necessary to complete your applet. [2 marks]