AWT Interview Questions

21 - Which TextComponent method is used to set a TextComponent to the read-only state?
setEnabled(boolean) method is use to set a TextComponent to the read-only state.
22 - How are the elements of a CardLayout organized?
CardLayout organize its element like a deck of card, one on top of other.
23 - What is the relationship between an event-listener interface and an event-adapter class?
If you implement event-listener interface you need to define all its method which may or may not be of use but by extending event-adapter class only required method need to define as event-adapter class has empty definition of all event-interface methods.
24 - What event results from the clicking of a button?
The ActionEvent event generated.
25 - How can a GUI component handle its own events?
GUI component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.
26 - How are the elements of a GridBagLayout organized?
GridBagLayout arrange elements in the grid form. however the elements may be of different sizes and may occupy more than one row or column of the grid.
27 - What is the difference between the paint() and repaint() methods?
Paint () method used were actual painting is done whereas repaint () method internally call to paint () to repaint.
28 - Which class is the immediate superclass of the Container class?
Component class is the immediate superclass of the Container class.
29 - How can the Checkbox class be used to create a radio button?
By associating Checkbox objects with a CheckboxGroup.
30 - What is the purpose of the enableEvents() method?
enableEvents() method use to enable a particular event of an object. This method is used by the objects whose prime responsibility is to handle events, by overriding their event-dispatch methods. An event normally enabled at time when a listener is added to an object for a specific event.
31 - What interface is extended by AWT event listeners?
java.util.EventListener interface is extended by AWT event listeners.
32 - What is a layout manager?
Layout Managers allow you to arrange GUI components on a container for presentation purposes. There are several layout manager:
  • BorderLayout
  • BoxLayout
  • CardLayout
  • FlowLayout
  • GridBagLayout
  • GridLayout

33 - What methods are used to get and set the text label displayed by a Button object?
button.setLabel("label"); and button.getLabel(); used to get and set the text label displayed by a Button object.
34 - Which Component subclass is used for drawing and painting?
Canvas class is used for drawing and painting.