Java Techies- Solution for All
AWT Interview Questions
1 - Name all subclasses of the Component class.The list of all subclasses of component class is as under:
2 - How Component class is used to set the position and size of a component?Component class use below mention method to set the position and size of a component
- setMaximumSize(Dimension maximumSize) set the maximum size of component.
- setMinimumSize(Dimension minimumSize) set the minimum size of the component.
- setAlignmentX(float x) set x coordinate or vertical alignment.
- setAlignmentY(float y) set y coordinate or horizontal alignment.
3 - What is the difference between a MenuItem and a CheckboxMenuItem?The MenuItem is a super class of CheckboxMenuItem that is CheckboxMenuItem extends MenuItem class to support the menu item that may be checked or unchecked.
4 - What is the purpose of using Event Handlers?Event Handling is use to perform some action on events, event are like button click event, mouse over event, mouse press and mouse release event, window close and open event etc. TO perform some task on occurrence of any of these events, event handling is used.
5 - What class is the top of the AWT event hierarchy?java.awt.AWTEvent class is the top most class of the AWT event hierarchy.
6 - How are the elements of a BorderLayout organized?The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.
7 - What is the difference between a Scrollbar and a ScrollPane?Scrollbar is a component and ScrollPane is a container.
8 - What is the difference between a Window and a Frame?
- A frame is a resizable, movable window with title bar and close button. It is derived from a window and has a BorderLayout by default.
- A window is a Container and has BorderLayout by default. A window must have a parent Frame mentioned in the constructor.
9 - Which container use a border Layout as their default layout?Window, Frame and Dialog class use border layout as their default layout.
10 - Which method is used to specify a container's layout?The setLayout() method is used to set a container's layout.
11 - Which containers use a FlowLayout as their default layout?Applet and Panel use a FlowLayout as their default layout.
12 - What is the immediate superclass of the Applet class?Panel is the immediate superclass of the Applet class.
13 - In which package are most of the AWT events that support the event-delegation model defined?In java.awt.event package.
14 - What is the immediate superclass of Menu?MenuItem class is the immediate superclass of Menu class.
15 - Which class is the immediate superclass of the MenuComponent class.Object class is the immediate superclass of the MenuComponent class.
16 - Which Container method is used to cause a container to be laid out and redisplayed?validate() method of Container class method is used to cause a container to be laid out and redisplayed.
17 - Name two subclasses of the TextComponent class.TextField and TextArea are two subclasses of the TextComponent class.
18 - What is the advantage of the event-delegation model over the earlier event-inheritance model?
- event-delegation enables the handling of events by objects.
- Application that generate more events, event-delegation perform must better there. The unhandled events not need to be repeatedly processed, which event-inheritance model not support.