Professional Documents
Culture Documents
24S - W08 - Final
24S - W08 - Final
PROGRAMMING IN JAVA
Assignment 8
TYPE OF QUESTION: MCQ
Number of questions: 10 Total marks: 10 × 1 = 10
QUESTION 1:
Correct Answer:
Detailed Solu�on:
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:
When we invoke repaint() for a java.awt.Component object, the AWT invokes which of the
following method ?
a. draw( )
b. show( )
c. update( )
Correct Answer:
c. update( )
Detailed Solu�on:
The repaint() method calls automa�cally update() method and in turn update() method calls
paint() method.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 3:
a. Only 1
b. Only 2
c. Both
d. None
Correct Answer:
c. Both
Detailed Solu�on:
A Frame object can be created using the Frame class itself as well as extending the Frame class.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 4:
Which AWT concept allows you to handle events such as button clicks or mouse movements?
a. Event Handling
b. Component Interac�on
c. Process Management
d. GUI Processing
Correct Answer:
a. Event Handling
Detailed Solu�on:
Event Handling in AWT enables the response to user ac�ons, such as buton clicks or mouse movements,
in a graphical user interface.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 5:
Which of the following methods can be used to change the size of a java.awt.Component object?
1. dimension()
2. setSize()
3. area()
4. size()
5. resetSize()
a. 1, 2, 3 & 5
b. 4 & 5
c. 1, 2 & 5
d. only 2
Correct Answer:
d. only 2
Detailed Solu�on:
The method setSize() can only be used to change the size of a component.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 6:
a. Checkbox is used for single selec�on item whereas radio buton is used for mul�ple selec�on.
b. Checkbox is used for mul�ple selec�on items whereas radio buton is used for single selec�on.
Correct Answer:
b. Checkbox is used for mul�ple selec�on items whereas radio buton is used for single selec�on.
Detailed Solu�on:
Checkbox is used for mul�ple selec�on items whereas radio buton is used for single selec�on. For
example, if a form is asking for your favorite hobbies, there might be mul�ple correct answers to it, in
that case checkbox is preferred. And if a form is asking about gender, there must be only one true op�on
among the mul�ple choices, in that case radio butons are used.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 7:
Correct Answer:
Detailed Solu�on:
AWT components are pla�orm-dependent and use na�ve components, whereas Swing components are
implemented in Java and are pla�orm-independent.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 8:
Correct Answer:
Detailed Solu�on:
AWT components provide the building blocks for crea�ng graphical user interfaces (GUIs) in Java
applica�ons.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 9:
import java.awt.*;
import java.awt.event.*;
b. Compila�on error
Correct Answer:
Detailed Solu�on:
The code creates a frame and adds a buton with the label "NPTEL – Programming in Java" at coordinates
(30, 50).
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.*;
import java.awt.event.*;
a. Border Layout
b. Flow Layout
c. Grid Layout
d. Card Layout
Correct Answer:
c. Grid Layout
Detailed Solu�on:
The code sets the layout manager of the 1frame to a 2x2 grid layout using frame.setLayout(new
GridLayout(2, 2)).