ProAnswers.org

What is an Applet? and what are the lifecycle methods for it?

1 Like

An applet is a java program which register on the server and will be executed in the client.

*[b]Life cycle methods[/b]:



1. [b]int()[/b]: This is the 1st method to be executed this method contains the code for initialization. This method will be executed only one time.



2. [b]start()[/b]: This method will be executed after init() method. This method contains business logic like connecting to files data bases processing the data, generating report etc. this method will be executed multiple times as long as the applet has the control.



3. [b]stop()[/b]: This method will be executed when the applet looses the control. This method contains a logic for the performing “cleanup activities”. This method will be executed multiple times when ever the applet looses the control.



4. [b]destroy()[/b]: This is the last method to be executed before terminating the applet. This method is used to destroy the applet. This method executed only one time.



[b]Note[/b]: when even destroy() method is called before invoking it will call stop() method.