A good answer might be:

The completed applet is given below.


Hello Applet

In this example applet, the x and y values for the start of the String are written as arithmetic expressions. The expression for x starts the string at the point half the string size to the left of half the drawing area's width. The expression for y starts the string at the point half the character size down from half the drawing area's height. Because going down the page means increasing Y, 10/2 is added to the center Y value. (There is a better way to do this, but it uses a few more methods.)

import java.applet.Applet;
import java.awt.*;

public class AnotherHello extends Applet
{
  public void paint ( Graphics gr )
  { 
    setBackground( Color.lightGray );
    gr.drawString("Hello", (300/2 - 40/2), (150/2 + 10/2) );
   }
}

Here is what the applet does with your Web browser:

Not all browsers can run applets. If you see this, yours can not.


QUESTION 6: