explain the significance of init and destroy


Explain the significance of init() and destroy( ) methods of an applet? Also explain two ways of invoking an applet.

The init( ) method is utilized for fundamental initialization in the applet. This is executed only once throughout the life time of the applet. It is the first method to be invoked while applet is started.

The destroy( ) method is utilized to clear the space from the memory while applet is stopped final ly.

Two ways are there to invoke an applet

  • Executing the applet inside a java compatible web browser or
  • By using an Applet viewer

In a web browser, to execute an applet a short HTML text file is written.

The HTML file to execute SimpleApplet is as follows:

< applet code = "SimpleApplet" width =200 height =60>

The height and width specifies the dimensions of the display area utilized.

To execute SimpleApplet with an applet viewer we will execute HTML file demonstrated above. For illustration if preceding HTML file is termed as app.HTML then the following command will execute a SimpleApplet:

C: \< appletviewer app.HTML

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: explain the significance of init and destroy
Reference No:- TGS0282759

Expected delivery within 24 Hours