Java Interview Questions - Applet

1. What is Applet?

It is a special type of program that is embedded in the webpage to generate the dynamic content.

2. Define lifecycle method of Applet in java?

To control applet program java provide 5 predefined method which is known as life cycle of applet. They are:

  1. Init()
  2. Start()
  3. Paint()
  4. Stop()
  5. Destroy ().

3. How to execute the Applet program?

Applet program can execute by web browser.

4. The immediate super class of the Applet class?

java.awt.Panel is the super class of Applet class.

5. What is the role of init() method under applets?

It is used to initialized the applet which invoked only once .In this method some block of statement perform one time operation.

6. Which method is called by Applet class to load an image?

Using the getImage() Methods

7. How does applet recognize the height and width?

<APPLET> is a predefined tag present in HTML. This tag having two attributes I.e. height and width which recognize the height and width of applet.

8. What is the default layout of an applet?

FlowLayout is the default layout of Applet.

9. How Applet program can run?

There are two ways to run an applet. They are:

  1. by html file
  2. by applet viewer tool.

10. Applet package contain how many class?

Applet package contain only one class.

11. Define Standalone application?

A standalone application is one which runs in the context of local disk and whose result is not shareable. Every standalone application runs from command prompt and it contains many method along with System.Out.Println statement.

12. Define Distributed application?

A distributed application is one which runs in the context of browser or world wide web & it can be accussed across the globe. It does not contain main method and System.out.println statement.

13. Which method call for a single time?

  1. Init()
  2. Destroy()

14. Which method comes under awt?

The Paint() method comes under awt.

15. State which class provide how many life cycle method?

java.applet.Applet class provide s 4 life cycle method and java. awt . component class provide 1 life cycle method.

16. What is java plug in software?

java plug-in software is responsible to manage the lifecycle of an applet.

17. What is the use of applet?

Applet is mostly used in Games and Animations.

18. Which method use to display the image?

java.awt.Graphics class provide drawImage() method to display the image.

19. Which class implements upon ImageObserver interface?

The component class implements upon Image observer interface.

20. Which class extends the applet class?

JApplet class extends the applet class.

21. Which method use for painting operation in applet?

Painting operation in applet done by mouseDragged() method of MouseMotionListener.

22. Which facility for communication class provide b/w applet?

java.applet.AppletContext class provides the facility for communication between applets.

23. Which method returns the object of Applet?

getApplet() method returns the object of applet.

24. Which method returns the object of image? Ans:

java.applet.Applet class provides getImage() method which return the object of image.