P5 Test Questions

(Project Test Home Page)

# Question
1 drawString()
Which class does the drawString() method reside in?
(Choose one)

A. java.applet.Applet
B. java.awt.Frame
C. java.awt.Graphics
D. None of the above

2 Applet
Which statements are true about Applets?
(Choose all that apply)

A. The browser that loads the Applet will instantiate the class.
B. The paint() method is automatically called and passed a java.awt.Graphics object.
C. Applet's that are JDK 1.1 compatible must extend java.applet.Applet.
D. None of the above

3 Which statements are correct about the sample code below?
(Choose all that apply)

import java.applet.Applet;
import java.awt.Graphics;

public class MyHello_Applet extends Applet {
  public void paint(Graphics g) {
    g.drawString("Hello World from an Applet.",10,50);
  }
}

A. Since setVisible(true) was not called you will see a blank screen.
B. Will not compile because there is no main() method.
C. Displays words starting 10 pixels down and 50 pixels across the screen. 
D. None of the above

4 drawString()
Which statements are correct about the sample code?

  public void paint(java.awt.Graphics g) {
    g.drawString("Hello World from an Applet.",10,50);
  }

A. Will not compile because drawString() is a method in java.applet.Applet.
B. 10 is the x coordinate.
C. 50 is the y coordinate.
D. None of the above

5 appletviewer
Which statements are correct about the appletviewer?

A. "appletviewer" is a program included in the JDK for programmers to view applets in html files.
B. "appletviewer" is included in the JRE.
C. "appletviewer" can view all of the html code along with the applet.
D. None of the above

6 Applet Tag
Which statements are correct about the sample html code.

<applet code="HelloWorld.class" codebase="."  width="275" height="55">

A. The class name should be the value of the codebase property, not code.
B. HelloWorld.class must exist in the same directory as the html file because codebase = "."
C. The viewable window of the applet in the browser will be 275 pixels by 55 pixels.
D. None of the above