Applets Self Test With Answers             


1) Which of the following does not run in the context of another program

a) stand-alone applications
b) an applet
c) a servlet
d) an enterprise java bean                                 ( a )
 

2) Which of the following is not a mandatory applet tag?

a ) code
b) width
c) height
d) codebase                                                             ( d )
 

3)  Mark the method that is not one of the standard methods overridden in an applet.

a) init( )
b) start( )
c) run( )
d) stop( )
e) paint( )                                                                  ( c  )
 

4) Which of the following lines is not correct in the following applet?

a)  import java.awt.*;
b)  import java.awt.applet.*;
c) public ThisApplet extends Applet {
d) public void paint( Graphics g){ g.drawString("Hi!", 10, 10 );  }
}

                                                                                    ( b )

// This points to the fact that early in Java's history Applets were
// the only 'show in town'  and had their own package. The correct
// import would be 'import java.applet.*; Note the newer JApplet
// is dovetailed into the swing package.  

5) The appletviewer utility

a) facilitates quick viewing of applets during development
b) requires as an argument a class file just as is passed to the 'java' command
c) can run  an html file or a java source file
d) to run an applet from source file the applet tag must be supplied and
   commented out.                                                    ( b )

// appletviewer needs something that acts as a document that in turn
// points to where a class file is          

    
6) True or False: Because the init( ) method of an applet acts like a
constructor, constructors cannot be used with applets.   ( False )

// We didn't cover this and is also just for your information. Applets
// are in everyway normal classes, so constructors can be used with
// them like other classses, ( excepting anomolies like the Math class.)

 

7) In which of the following methods of the applet life cycle is the recommended
     location for building GUIs.

a) init( )
b) start( )
c) paint( )
d) stop( )                                                            ( a )


8) Which of the following statements is not correct. While accessing
parameters from the applet tag

a) The Param tag has a NAME and and a VALUE component
b) an applets getParameter( ) method argument must match case sensitive
    with the value assigned to the NAME attribute in the PARAM tag.
c) The PARAM tag is located between the two applet tags
d) The PARAM tag does not need a closing </ PARAM> tag   ( b )

// This is a hard question, if just for the English, my apologies. Going into
// the getParameter( ) method, the string is really part of the HTML world
// of doing things and so is not expected to be case sensitive.