Practice objective questions
for quick revision and examination
preparation. Try answering each question
before revealing the answer.
π Object Oriented Programming through Java
π Unit 4
π― MCQs
Object Oriented Programming through Java - Unit-4
1
Give the abbreviation of AWT?
AApplet Windowing Toolkit
BAbstract Windowing Toolkit
CAbsolute Windowing Toolkit
DNone of the above
Correct AnswerAbstract Windowing Toolkit
2
Which is the container that contain title bar and can have MenuBars. It can have other components like button, textfield etc.?
APanel
BFrame
CWindow
DContainer
Correct AnswerFrame
3
Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?
AWindow
BContainer
CPanel
DFrame
Correct AnswerContainer
4
Which class provides many methods for graphics programming?
Ajava.awt
Bjava.Graphics
Cjava.awt.Graphics
DNone of the above
Correct Answerjava.awt.Graphics
5
_________ concept is used to create a Frame
Aencapsulation
Binheritance
Cabstraction
Dpolymorphism
Correct Answerinheritance
6
The Following steps are required to perform 1) Implement the Listener interface and overrides its methods. 2) Register the component with the Listener.
AException Handling
BString Handling
CEvent Handling
DNone of the above
Correct AnswerEvent Handling
7
In which places can put the event handling code
ASame class
BOther class
CAnnonymous class
DAll mentioned above
Correct AnswerAll mentioned above
8
Which package provides many event classes and Listener interfaces for event handling?
Ajava.awt
Bjava.awt.Graphics
Cjava.awt.event
DNone of the above
Correct Answerjava.awt.event
9
To use the ActionListener interface it must be implemented by a class there are several ways to do that find in the following?
ACreating a new class
Busing the class the graphical component
Can anonymous inner class
DAll mentioned above
Correct AnswerAll mentioned above
10
The __________________ interface is not used for handling action events?
AActionListener
BKeyListener
CMouseListener
DItemListener
Correct AnswerActionListener
11
Which is the container that doesn't contain title bar and MenuBars but it can have other components like button, textfield etc?
AWindow
BFrame
CPanel
DContainer
Correct AnswerPanel
12
Which method is used to set the graphics current color to the specified color in the graphics class?
Apublic abstract void setFont(Font font)
Bpublic abstract void setColor(Color c)
Cpublic abstract void drawString(String str, int x, int y)
DNone of the above
Correct Answerpublic abstract void setColor(Color c)
13
The ActionListener interface is used for handling action events,For example,it's used by a
AButton
BCheckbox
CMenuItem
DAll of these
Correct AnswerAll of these
14
In Graphics class which method is used to draws a rectangle with the specified width and height?
Apublic void drawRect(int x, int y, int width, int height)
Bpublic abstract void fillRect(int x, int y, int width, int height)
Cpublic abstract void drawLine(int x1, int y1, int x2, int y2)
Dpublic abstract void drawOval(int x, int y, int width, int height)
Correct Answerpublic void drawRect(int x, int y, int width, int height)
15
Which object can be constructed to show any number of choices in the visible window?
ALabels
BChoice
CList
DCheckbox
Correct AnswerList
16
Which method can set or change the text in a Label?
AsetText()
BgetText()
CText()
DNone of the above
Correct AnswersetText()
17
Which is a component in AWT that can contain another components like buttons, textfields, labels etc.?
AWindow
BContainer
CPanel
DFrame
Correct AnswerContainer
18
Which are passive controls that do not support any interaction with the user?
AChoice
BList
CLabels
DCheckbox
Correct AnswerLabels
19
Which package provides many event classes and Listener interfaces for event handling?
Ajava.awt
Bjava.awt.Graphics
Cjava.awt.event
DNone of the above
Correct Answerjava.awt.event
20
Where can the event handling code be written?
ASame class
BOther class
CAnonymous class
DAll mentioned above
Correct AnswerAll mentioned above
21
Which is the container that doesn't contain title bar and MenuBars but it can have other components like button, textfield etc?
AWindow
BFrame
CPanel
DContainer
Correct AnswerPanel
22
The concept of the menu bar can be implemented by using three java classesβ
AMenuBar
BMenu
CMenuItem
DAll of these
Correct AnswerAll of these
23
In Java an event is an _______which specifies the change of state in the source.
AClass
BObject
CInt
DString
Correct AnswerObject
24
The classes and interfaces defined in AWT are contained within the ______ package.
Ajava.awt.*
Bjava.sql.*
Cjava.io.*
Djava.int*
Correct Answerjava.awt.*
25
The general form to set a specific type of layout manager is _________
Avoid setLayout(LayoutManager lm)
BVoid setLayout(LayoutManager lm)
Cvoid setLayout(layoutManager lm)
DVoid setLayout(Layoutmanager lm)
Correct Answervoid setLayout(LayoutManager lm)
26
A checkbox is a control that consists of a _____________
ACombination of a small box
BA label
CCombination of a large box and a label
DBoth A & B
Correct AnswerBoth A & B
27
An event is generated when the internal state of the event source is________
ANot changed
BChanged
CEither changed or not
DNone of these
Correct AnswerChanged
28
Positions the components into five regions:east, west, north, south, center
ABorderLayout
BCardLayout
CGridLayout
DFlowLayout
Correct AnswerBorderLayout
29
Arranges the components as a deck of cards such that only one component is visible at a time
ABorderLayout
BCardLayout
CGridLayout
DFlowLayout
Correct AnswerCardLayout
30
Arranges the components horizontally
ABorderLayout
BCardLayout
CGridLayout
DFlowLayout
Correct AnswerFlowLayout
31
Arranges the componemnts into grid
ABorderLayout
BCardLayout
CGridLayout
DFlowLayout
Correct AnswerGridLayout
32
__________ creates a dropdown list of textual entries
AChoice
BCheckbox
CTextbox
DTextComponent
Correct AnswerChoice
33
How many types of events are there?
A5
B3
C2
D4
Correct Answer2
34
To manage events, Java employs the ____?
ACustom-based Event Model
BRetired Event Model
CDelegation Event Model
DNone of the above
Correct AnswerDelegation Event Model
35
____ are classes that act as a connection point between event listeners and event sources?