Awt Swing Interview Questions

Awt Swing Interview Questions

1 what is the difference between a Choice and a List?

Ans: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.

2 what interface is extended by AWT event listeners?

Ans: All AWT event listeners extend the java.util.EventListener interface.

3 what is a layout manager?

Ans: A layout manager is an object that is used to organize components in a container.

4 Which Component subclass is used for drawing and painting?

Ans: Canvas

5 what is the difference between a Scrollbar and a Scroll Pane?

Ans: A Scrollbar is a Component, but not a Container. A Scroll Pane is a Container. A Scroll Pane handles its own events and performs its own scrolling.

6 Which Swing methods are thread-safe?

Ans: The only thread-safe methods are repaint (), revalidate (), and invalidate ()

7 which containers use a border Layout as their default layout?

Ans: The Window, Frame and Dialog classes use a border layout as their default layout

8 what is the preferred size of a component?

Ans: The preferred size of a component is the minimum component size that will allow the component to display normally

9 which containers use a Flow Layout as their default layout?

Ans: The Panel and Applet classes use the Flow Layout as their default layout

10 what is the immediate super class of the Applet class?

Ans: Panel

11 Name three Component subclasses that support painting?

Ans: The Canvas, Frame, Panel, and Applet classes support painting

12 what is the immediate super class of the Dialog class?

Ans: Window

13 what is clipping?

Ans: Clipping is the process of confining paint operations to a limited area or shape.

14 what is the difference between a Menu Item and a Check box MenuItem?

Ans: The Checkbox Menu Item class extends the MenuItem class to support a menu item that may be checked or unchecked.

15 what class is the top of the AWT event hierarchy?

Ans: The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy

16 In which package are most of the AWT events that support the event-delegation model defined?

Ans: Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.

17 which class is the immediate super class of the Menu Component class?

Ans: Object

18 which containers may have a Menu Bar?

Ans: Frame

19 what is the relationship between the Canvas class and the Graphics class?

Ans: A Canvas object provides access to a Graphics object via its paint () method.

20 How are the elements of a Border Layout organized?

Ans: The elements of a Border Layout are organized at the borders (North, South, East, and West) and the center of a container.