Programming in Java Assignment 8: NPTEL Online Certification Courses Indian Institute of Technology Kharagpur
Programming in Java Assignment 8: NPTEL Online Certification Courses Indian Institute of Technology Kharagpur
Programming in Java Assignment 8: NPTEL Online Certification Courses Indian Institute of Technology Kharagpur
PROGRAMMING IN JAVA
Assignment 8
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 × 1 = 10
______________________________________________________________________________
QUESTION 1:
In Java AWT, TextArea and TextField are the subclass of
a. List
b. Label
c. TextComponent
d. TextBox
Correct Answer: c
Detailed Solution:
TextArea and TextField are the two sub classes of TextComponent in Java AWT.
.
___________________________________________________________________
QUESTION 2:
The class at the top of the AWT hierarchy is
a. Component
b. Window
c. Container
d. Frame
Correct Answer: a
Detailed Solution:
Others are the sub classes of the Component class.
_____________________________________________________________________
QUESTION 3:
Which of the following packages provides many methods for graphics programming?
a. java.awt
b. java.Applet
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
c. java.Graphics
d. java.io
Correct Answer: a
Detailed Solution:
There is no package like java.Graphics and java.Applet. The Graphics class and other classes,
which are necessary for GUI programming is defined in java.awt package.
_________________________________________________________________________
QUESTION 4:
When we invoke repaint() for a java.awt.Component object, the AWT invokes which of the
following method ?
a. draw( )
b. show( )
c. update( )
d. paint( )
Correct Answer: c
Detailed Solution:
The repaint() method calls automatically update() method and in turn update() method calls
paint( ) method.
_________________________________________________________________
QUESTION 5:
Which of the following statement(s) is/are correct?
Correct Answer: d
Detailed Solution:
AWT components are platform dependent and not follow MVC. Swing components follow
MVC and are platform independent.
______________________________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 6:
What is the name of the method used to get the timestamp of an event in AWT ActionEvent
Class ?
a. getWhen().
b. getModifiers().
c. paramString().
d. getActionCommand().
Correct Answer: a
Detailed Solution:
getWhen( ) method of ActionEvent class returns the timestamp of the event when it is occurred.
___________________________________________________________________________
QUESTION 7:
What invokes immediately after the start() method in an applet?
a. stop()
b. init()
c. paint()
d. destroy()
Correct Answer: c
Detailed Solution:
There are five important methods in applet programming: init(), start(), paint(), stop() and
destroy(). The executions of these methods are in the aforementioned stated order only.
_____________________________________________________________________________
QUESTION 8:
Which of the following methods is called only once during the run time of an applet?
e. stop()
f. paint()
g. init()
h. destroy()
Correct Answer: c
Detailed Solution:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
_____________________________________________________________________________
QUESTION 9:
Which of the following methods can be used to change the size of a java.awt.Component
object?
(A) dimension()
(B) setSize()
(C) area()
(D) size()
(E) resize()
Correct Answer: d
Detailed Solution:
The two methods, namely setSize() and resize() can be used to change the size of a component.
___________________________________________________________________________
QUESTION 10:
What is the name of the method used to retrieve the label of a button in AWT?
Correct Answer: a
Detailed Solution: getLabel() method of Button class is used to retrieve the label of a button.
.
______________________________________________________________________________