50+ TOP Java AWT Interview Questions and Answers [UPDATED]

If you’re preparing for Java AWT job interview and whether you’re experienced or fresher & don’t know what kind of questions will be asked in Java AWT interview, then go through the below Real Time 50+ Top Java AWT(Abstract Window Toolkit) Interview Questions and Answers to crack your job interview.

Java AWT Interview Questions and Answers

  • Question: Define Canvas?

    Answer :

    It is a simple drawing surface which is used for painting images or to perform other graphical operations.

    What is the difference between the Font and FontMetrics classes?

    The FontMetrics class is used to define implementation specific properties such as ascent and descent, of a Font object.

  • Question: Explain The Use Of Update Method?

    Answer :

    An update method is called on calling the repaint method.

    The default implementation of the update() method clears the screen and calls the paint() method.

  • Question: How Are The Elements Of Different Layouts Organized?

    Answer :

    FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion.

    Border Layout: The elements of a BorderLayout are organized at the borders and the centre of a container.

    CardLayout: The elements of a CardLayout are stacked, on the top of the other, like a deck of cards.

    GridLayout: The elements of a GridLayout are equal size and are laid out using the square of a grid.

    GridBagLayout: The elements of a GridBagLayout are organized according to a grid.

  • Question: How Can We Get All Public Methods Of An Object Dynamically?

    Answer :

    getMethods(): It return an array of method objects corresponding to the public methods of this class.

    getFields(): It returns an array of Field objects corresponding to the public Fields (variables) of this class.

    getConstructors: It returns an array of constructor objects corresponding to the public constructors of this class.

  • Question: Name Components Subclasses That Support Painting?

    Answer :

    • The Canvas
    • Frame
    • Panel and
    • Applet classes support painting
  • Question: What Are Awt Peers?

    Answer :

    A component is associated with a standard AWT button object, a peer object and an interfacing button object constructed per the native GUI.

  • Question: What Are The Benefits Of Swing Over Awt?

    Answer :

    • Swing components are light weight.
    • We can have a pluggable look and feel feature which shows us how they appear in other platforms.
    • We can add images to Swing components. We have toolbars and tooltips in Swing.
  • Question: What Are The Component And Container Class?

    Answer :

    A component is a graphical object.

    A few examples of components are:

    • Button
    • Canvas
    • Checkbox
    • Choice etc.
  • Question: What Are The Default Layouts For A Applet, A Frame And A Panel?

    Answer :

    For an applet and a panel, Flow layout, and The FlowLayout manager attempts to honor the preferred size of any components.

  • Question: What Are The Different Types Of Controls In Awt?

    Answer :

    The AWT supports the following types of controls:

    • Labels, Pushbuttons, Checkboxes, Choice lists, Lists, Scroll bars, Text components
    • These controls are subclasses of component.
  • Question: What Are The Subclass Of Textcomponent Class?

    Answer :

    TextField and TextArea

  • Question: What Are The Subclasses Of The Container Class?

    Answer :

    The container class has three major subclasses.

    They are:

    • Window
    • Panel
    • ScrollPane
  • Question: What Are The Types Of Checkboxes?

    Answer :

    Java supports two types of checkboxes.

    They are:

    • Exclusive and
    • Non exclusive
  • Question: What Interface Is Extended By Awt Event Listener?

    Answer :

    The java.util.EventListener interface is extended by all the AWT event listeners.

  • Question: What Is A Container In A Gui?

    Answer :

    A Container contains and arranges other components through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

  • Question: What Is A Layout Manager?

    Answer :

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

  • Question: What Is Clipping?

    Answer :

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

  • Question: What Is Meant By Controls?

    Answer :

    Controls are components that allow a user to interact with your application.

  • Question: What Is Paint Method?

    Answer :

    The AWT uses a Callback mechanism for painting which is the same for heavyweight and lightweight components.

  • Question: What Is The Default Layout For Applet?

    Answer :

    The default layout manager for an Applet is FlowLayout, and the FlowLayout manager attempts to honor the preferred size of any components.

  • Question: What Is The Difference Between A Menuitem And A Checkboxmenuitem?

    Answer :

    The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.

  • Question: What Is The Difference Between A Scrollbar And A Scrollpane?

    Answer :

    • A Scrollbar is a component, but not a container.
    • A Scrollpane is a container.
    • A Scrollpane handles its own events and performs its own scrolling.
  • Question: What Is The Difference Between A Swing And Awt Components?

    Answer :

    • AWT components re heavy weight, whereas Swing components are lightweight.
    • Heavy weight components depend on the local windowing toolkit.

    For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.

  • Question: What Is The Difference Between A Window And A Frame?

    Answer :

    The Frame class extends Window to define a main application window that can have a menu bar.

  • Question: What Is The Difference Between Choice And List?

    Answer :

    A choice is displayed in a compact from that requires you to pull it down to see the list of available choices and only one item may be selected from a choice.

    A list may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.

  • Question: What Is The Difference Between Exclusive And Non Exclusive?

    Answer :

    Exclusive: Only one among a group of items can be selected at a time. If an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons.

    Non Exclusive: Checkboxes are not grouped together and each one can be selected of the other.

  • Question: What Is The Difference Between Grid And Gridbaglayout?

    Answer :

    In Grid layout the size of each grid is constant where as in GridbagLayout grid size can varied.

  • Question: What Is The Difference Between The Paint() And Repaint() Method?

    Answer :

    • The paint() method supports painting via a Graphics object.
    • The repaint() method is used o cause paint() to be invoked by the AWT painting thread.
  • Question: What Is The Parameter Specification For The Public Static Void Main Method?

    Answer :

    • String args []
    • String [] args
  • Question: What Is The Purpose Of Repaint Method?

    Answer :

    repaint() requests can erase and redraw (update) after a small time display. When you invoke repaint().

  • Question: What Is The Use Of The Window Class?

    Answer :

    • The window class can be used to create a plain, bare bones window that does not have a border or menu.
    • The window class can also be used to display introduction or welcome screens.
  • Question: Where The Cardlayout Is Used?

    Answer :

    CardLayout is used where we need to have a bunch of panel or frames one laying over another. It is replaced by TabbedPane in Swing.

  • Question: Which Component Subclass S Used For Drawing And Painting?

    Answer :

    Canvas

  • Question: Which Container May Contain A Menu Bar?

    Answer :

    Frame

  • Question: Which Containers Use A Border Layout As Their Default Layout?

    Answer :

    Window Frame and Dialog classes use a Border Layout as their layout.

  • Question: Which Containers Use A Flowlayout As Their Default Layout?

    Answer :

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

  • Question: Which Method Is Method To Set The Layout Of A Container?

    Answer :

    setLayout ()

  • Question: Which Method Will Cause A Frame To Be Displayed?

    Answer :

    • .show()
    • .setVisible()