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?
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?
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?
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?
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?
- The Canvas
- Panel and
- Applet classes support painting
Question: What Are Awt Peers?
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?
- 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?
A component is a graphical object.
A few examples of components are:
- Choice etc.
Question: What Are The Default Layouts For A Applet, A Frame And A Panel?
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?
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?
TextField and TextArea
Question: What Are The Subclasses Of The Container Class?
The container class has three major subclasses.
Question: What Are The Types Of Checkboxes?
Java supports two types of checkboxes.
- Exclusive and
- Non exclusive
Question: What Interface Is Extended By Awt Event Listener?
The java.util.EventListener interface is extended by all the AWT event listeners.
Question: What Is A Container In A Gui?
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?
A layout manager is an object that is used to organize components in a container.
Question: What Is Clipping?
Clipping is the process of confining paint operations to a limited area or shape.
Question: What Is Meant By Controls?
Controls are components that allow a user to interact with your application.
Question: What Is Paint Method?
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?
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?
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?
- 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?
- 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?
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?
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?
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?
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?
- 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?
- String args 
- String  args
Question: What Is The Purpose Of Repaint Method?
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?
- 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?
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?
Question: Which Container May Contain A Menu Bar?
Question: Which Containers Use A Border Layout As Their Default Layout?
Window Frame and Dialog classes use a Border Layout as their layout.
Question: Which Containers Use A Flowlayout As Their Default Layout?
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?
Question: Which Method Will Cause A Frame To Be Displayed?