1. Correct these statements so they are true. Do not simply add a ‘not’ to each statement, truly correct them.
(a) Methods go inside classes.
(b) The java.awt.* class has code to write System.out statements.
(c) If you had the code g.drawRect(20,30,100,120), its top left corner would be at 20,30 and its bottom right corner would be at 100,120.
(d) g.fillPolygon would draw the outline of a polygon on the screen.
(e) Co-ordinate 0,0 is in the bottom right corner of the screen
2. Look at the following code:
//__1_____________________ //__2_____________________ //__3_____________________ import java.io.*; import javax.swing.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*;
public class j extends Applet
{
public void paint (Graphics g)
{
//_4_____________________
g.setColor (Color.orange);
g.fillOval (10, 40, 190, 130);
//___5_____________________ g.setColor (Color.green); g.fillRect (90, 10, 20, 30);
//___6_____________________ g.drawLine (30, 170, 170, 170);
//___7_____________________
g.setColor (Color.black);
int XArray [] = {75, 60, 90, 75};
int YArray [] = {55, 90, 90, 55};
g.fillPolygon (XArray, YArray, 4);
//___8______________________
int XArray2 [] = {125, 110, 140, 125};
g.fillPolygon (XArray2, YArray, 4);
//___9______________________
int XArray3 [] = {55, 150, 140, 125, 120, 100, 90, 75, 65, 55};
int YArray3 [] = {125, 125, 150, 135, 150, 150, 135, 150, 150, 125};
g.fillPolygon (XArray3, YArray3, 10);
}
}
(a) Draw what this code draws. Label the colours.
(b) Add the appropriate comments to the code.
(c) Cross out the three unnecessary libraries.
(d) What method is used in this program?
(e) What name should this file be saved as?