0% found this document useful (0 votes)
3 views3 pages

Java_AWT_Notes_for_MCQ

AWT (Abstract Window Toolkit) is a Java framework for creating GUI applications using native OS components, resulting in platform-dependent appearances. It includes a class hierarchy with components like Label, Button, and TextField, and employs event-driven programming through listener interfaces. AWT differs from Swing by using heavyweight components and is less feature-rich, with examples and practice MCQs provided for better understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Java_AWT_Notes_for_MCQ

AWT (Abstract Window Toolkit) is a Java framework for creating GUI applications using native OS components, resulting in platform-dependent appearances. It includes a class hierarchy with components like Label, Button, and TextField, and employs event-driven programming through listener interfaces. AWT differs from Swing by using heavyweight components and is less feature-rich, with examples and practice MCQs provided for better understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Java AWT Notes for MCQ Exam

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.

AWT Class Hierarchy

java.lang.Object -> java.awt.Component -> java.awt.Container -> (Panel, Window, Frame, Dialog, Applet).

Component is the base class for all GUI items.

Container is a component that can hold other components.

Frame and Panel are containers that hold GUI elements like buttons, text fields, etc.

Common AWT Components

- Label: Displays non-editable text.

- Button: A clickable button.

- TextField: Single-line text input.

- TextArea: Multi-line text input.

- Checkbox: For multiple options.

- Choice: Drop-down menu.

- List: List of items to choose from.

- Canvas: Custom drawing area.

- Scrollbar: Vertical or horizontal scroll control.

Event Handling in AWT

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).

Swing provides more features and is platform-independent in look and feel.

AWT Programming Example

import java.awt.*;

public class AwtExample {

public static void main(String[] args) {

Frame f = new Frame("AWT Example");

Button b = new Button("Click Me");

b.setBounds(100, 100, 80, 30);

f.add(b);

f.setSize(300, 200);

f.setLayout(null);

f.setVisible(true);

Sample MCQs for Practice

1. Which class is the parent of all AWT components?

a) Object

b) Component

c) Container

d) Panel

Answer: b

2. What is the use of the Button class in AWT?

a) Display text

b) Accept text input

c) Create clickable button

d) Draw shapes
Java AWT Notes for MCQ Exam

Answer: c

3. Which class is used to create a window with title bar?

a) Applet

b) Panel

c) Frame

d) Container

Answer: c

4. Which component allows multi-line text input?

a) TextField

b) TextArea

c) Label

d) Button

Answer: b

5. AWT is platform-________ in appearance.

a) dependent

b) independent

Answer: a

You might also like