Java_AWT_Notes_for_MCQ
Java_AWT_Notes_for_MCQ
Introduction to AWT
AWT (Abstract Window Toolkit) is a part of Java used to create GUI (Graphical User Interface) applications. It
contains classes for windows, buttons, text boxes, and more. AWT uses native OS components, meaning it
looks different on each platform (Windows, Mac, Linux). AWT is platform-independent in execution but
platform-dependent in appearance.
java.lang.Object -> java.awt.Component -> java.awt.Container -> (Panel, Window, Frame, Dialog, Applet).
Frame and Panel are containers that hold GUI elements like buttons, text fields, etc.
AWT uses event-driven programming. Components generate events when users interact (click, type, etc.).
Java provides listener interfaces like ActionListener, MouseListener, etc., to handle these events.
Example: button.addActionListener(this);
AWT vs Swing
Java AWT Notes for MCQ Exam
AWT uses native OS components (heavyweight), while Swing uses Java components (lightweight).
import java.awt.*;
f.add(b);
f.setSize(300, 200);
f.setLayout(null);
f.setVisible(true);
a) Object
b) Component
c) Container
d) Panel
Answer: b
a) Display text
d) Draw shapes
Java AWT Notes for MCQ Exam
Answer: c
a) Applet
b) Panel
c) Frame
d) Container
Answer: c
a) TextField
b) TextArea
c) Label
d) Button
Answer: b
a) dependent
b) independent
Answer: a