Logo F2FInterview

Applet Interview Questions

Q   |   QA

Applets are certified by certain centralized agencies. Only those with a valid certification will be given access to vulnerable resources. This method of certification ensures a high level of security.

(This is one of the easiest question that you can expect). Similar to normal JAVA applications, java applets are compiled into bytecode before being served as applets. Bytecode is compatible across operating systems. This makes the applets compatible across operating systems too.

The paint() method is called in situations the applet window being overwritten by another window or uncovered or the applet window being resized.

The paint() is also called when the applet begins execution. The paint() method has one parameter of type Graphics which is needed to know the location wher the applet is supposed to paint its output.

The update() is called when a portion of its window be redrawn. It is defined by the AWT.

However, the update() first fills an applet with the default background colour and then calls paint() due to which an instance of the default color appears each time update is called.

Thus update() method should be overridden to avoid this situation.

The getParameter() method can be used within the init method to access the parameter data. It takes the parameter name as an argument.

public void init() {
      String val = getParameter("foreground-color");
}

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class Audio1Applet extends Applet implements ActionListener{
      Button play,stop;
     AudioClip audioClip;
  public void init(){
          play = new Button(" Play ");
          add(play);
          play.addActionListener(this);
          stop = new Button(" Stop ");
          add(stop);
          stop.addActionListener(this);
          audioClip = getAudioClip(getCodeBase(), "abc.wav");
  }

   public void actionPerformed(ActionEvent ae){
          Button source = (Button)ae.getSource();
          if (source.getLabel() == " Play "){
                  audioClip.play();
          }
          else if(source.getLabel() == " Stop "){
                  audioClip.stop();
          }
    }
}

<APPLET CODE="Audio1Applet" WIDTH="100" HEIGHT= "100"></APPLET>

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: