Assignment 8 solution
Assignment 8 solution
PROGRAMMING IN JAVA
Assignment 08
TYPE OF QUESTION: MCQ
Number of questions: 10 Total marks: 10 × 1 = 10
QUESTION 1:
Correct Answer:
The Abstract Window Toolkit (AWT) is Java's original pla orm-dependent windowing, graphics, and user-
interface widget toolkit, preceding Swing.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 2:
Correct Answer:
Card Layout allows you to manage mul ple panels within a single container, where only one panel is
visible at a me.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 3:
Which layout manager divides the container into five regions: North, South, East, West, and Center?
Border Layout
Grid Layout
Flow Layout
Card Layout
Correct Answer:
Border Layout
Border Layout divides the container into five regions, and components can be added to each region:
North, South, East, West, and Center.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 4:
Correct Answer:
A layout manager in Java is responsible for arranging and posi oning GUI components within a container.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 5:
import java.awt.*;
import java.awt.event.*;
Compila on error
Correct Answer:
The code creates a frame and adds a bu on with the label "Programming in Java - 2024" at coordinates
(30, 50).
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 6:
Which layout manager arranges components in a top-to-bottom flow, adding them to the next
available position?
Grid Layout
Flow Layout
Border Layout
Card Layout
Correct Answer:
Flow Layout
Flow Layout arranges components in a top-to-bo om, le -to-right flow, adding them to the next
available posi on in the container.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 7:
Correct Answer:
AWT components being heavyweight means they rely on the na ve components of the underlying
opera ng system, which can affect their appearance and behavior.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 8:
Which AWT concept allows you to handle events such as button clicks or mouse movements?
Event Handling
Func on Overloading
Mouse Manager
GUI Processing
Correct Answer:
Event Handling
Event Handling in AWT enables the response to user ac ons, such as bu on clicks or mouse movements,
in a graphical user interface.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 9:
Which layout manager organizes components in a grid, with each cell of the grid containing a
component?
Flow Layout
Grid Layout
Border Layout
Card Layout
Correct Answer:
Grid Layout
Grid Layout organizes components in a grid, and each cell of the grid contains a component.
Components are added in a le -to-right, top-to-bo om order.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 10:
What is the layout manager used in the Java code given below?
import java.awt.*;
Grid Layout
Border Layout
Flow Layout
Card Layout
Correct Answer:
Grid Layout
The code sets the layout manager of the 1frame to a 2x2 grid layout using frame.setLayout(new
GridLayout(2, 2)). The FlowLayout gets overridden by the GridLayout, you can try to comment
out the GridLayout line to see the difference.