Applet AWT Swing Java Interview Questions – Set 01

What is “applet”?

A J2EE component that typically executes in a Web browser but can execute in a variety of otherapplications or devices that support the applet programming model.

What are the components of J2EE application?

A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:

  • Application clients and applets are client components.
  • Java Servlet and JavaServer PagesTM (JSPTM) technology components are web components.
  • Enterprise JavaBeansTM (EJBTM) components (enterprise beans) are business components.
  • Resource adapter components provided by EIS and tool vendors.

What is “applet container”?

A J2EE component that typically executes in a Web browser but can execute in a variety of otherapplications or devices that support the applet programming model.

When do you use codebase in applet

When the applet class file is not in the same directory, codebase is used.

What is the immediate superclss of the Applet class

Panel.

Is it possible to communicate from an applet to servlet and how many ways and how

Yes, there are three ways to communicate from an applet to servlet and they are: a) HTTP Communication(Text-based and object-based) b) Socket Communication c) RMI Communication

In which package is the applet class located?

Applet classes are located in ” java.applet “package.

Which containers use a FlowLayout as their default layout?

The Panel and Applet classes use the FlowLayout as their default layout.

What is meant by controls and what are different types of controls in AWT?-

Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component.

What is the lifecycle of an applet

?– init() method – Can be called when an applet is first loaded start() method – Can be called each time an applet is started. paint() method – Can be called when the applet is minimized or maximized. stop() method – Can be used when the browser moves off the applet’s page. destroy() method – Can be called when the browser is finished with the applet.