☑ MCQ PRACTICE

Object Oriented Programming through Java Unit 5

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Object Oriented Programming through Java
📖 Unit 5
🎯 MCQs

Object Oriented Programming through Java - Unit-5

1
Which of these functions is called to display the output of an applet?
Adisplay()
Bpaint()
CdisplayApplet()
DPrintApplet()
Correct Answer paint()
2
Which package contains the Java Swing classes?
Ajava.lang
Bjava.io
Cjava.util
Djavax.swing
Correct Answer javax.swing
3
Which layout manager is used by default for JFrame?
ABorderLayout
BFlowLayout
CGridLayout
DCardLayout
Correct Answer BorderLayout
4
Which class is used to create a button in Java Swing?
AJButton
BJLabel
CJRadioButton
DJTextArea
Correct Answer JButton
5
What is the purpose of the setVisible() method in JFrame?
ATo set the size of the frame
BTo set the title of the frame
CTo make the frame visible on the screen
DTo close the frame
Correct Answer To make the frame visible on the screen
6
Which of these methods can be used to output a string in an applet?
Adisplay()
Bprint()
CdrawString()
Dtransient()
Correct Answer drawString()
7
Which of these methods is a part of Abstract Window Toolkit (AWT)?
Adisplay()
Bpaint()
CdrawString()
Dtransient()
Correct Answer paint()
8
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
Atransient
Bvolatile
Cglobal
DNo modifier is needed
Correct Answer volatile
9
Which of these operators can be used to get run time information about an object?
AgetInfo
BInfo
Cinstanceof
Dgetinfoof
Correct Answer instanceof
10
______________________ follows MVC (Model View Controller) architecture.
ASwing
BAWT
CBoth A & B
DNone of the above
Correct Answer Swing
11
_________ is not a part of JFC (Java Foundation Classes) that is used to create GUI application?
ASwing
BAWT
CBoth A & B
DNone of the above
Correct Answer Swing
12
The ActionListener interface is used for handling action events,For example,it's used by a
AJButton
BJCheckbox
CJMenuItem
DAll of these
Correct Answer All of these
13
Java applets are used to create _______________ applications
AGraphical
BUser interactive
CBoth a & b
DNone of these
Correct Answer Both a & b
14
An Applet is a ________ of Panel:
ASubclass
BSuperclass
CBoth a & b
DNone of these
Correct Answer Subclass
15
Which method is used to add components to a container in Java Swing?
Aadd()
BsetComponent()
Cinsert()
Dappend()
Correct Answer add()
16
Which class is a subclass of Component?
AContainer
BWindow
CFrame
Dnone
Correct Answer Container
17
What is the purpose of the setLayout() method in Java Swing?
ATo set the background color of a component
BTo set the size of a component
CTo set the layout manager for a container
DTo set the font style for a component
Correct Answer To set the layout manager for a container
18
The ____ method is used to obtain the current size of a window.
AgetSize()
BsetSize()
CNone
DBoth
Correct Answer getSize()
19
Which class is used to display text in Java Swing?
AJTextField
BJTextArea
CJLabel
DJList
Correct Answer JLabel
20
Which class is used to display images in Java Swing?
AJButton
BJLabel
CJRadioButton
DJTextArea
Correct Answer JLabel
21
Which of these events will be generated if we close the applet?
AActionListener
BItemListener
CMouseListener
DWindowListener
Correct Answer WindowListener
22
What is the default layouts for a applet, a frame and a panel?
AFlow layout, Border layout, Flow layout
BFlow layout, Flow layout, Border layout
CBorder layout, Flow layout, Flow layout
DBorder layout,Border layout, Flow layout
Correct Answer Flow layout, Border layout, Flow layout
23
An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager?
AsetLayoutManager(new GridLayout());
BsetLayout(new GridLayout(2,2));
CsetGridLayout(2,2,))
DsetBorderLayout();
Correct Answer setLayout(new GridLayout(2,2));
24
Which method is used to set the text content of a JTextField?
AsetText()
Bappend()
CsetLabel()
DsetContent()
Correct Answer setText()
25
Which of the following architecture does the Swing framework use?
AMVC
BMVP
CLayered architecture
DMaster-Slave architecture
Correct Answer MVC
26
What is the purpose of the setDefaultCloseOperation() method in JFrame?
ATo set the size of the frame
BTo set the title of the frame
CTo specify the default close operation for the frame
DTo close the frame
Correct Answer To close the frame
27
Which class is used to display tabbed panes in Java Swing?
AJTabbedPane
BJSlider
CJProgressBar
DJSpinner
Correct Answer JTabbedPane
28
The ………………… method called the first time an applet is loaded into the memory of a computer.
Ainit()
Bstart()
Cstop()
Ddestroy()
Correct Answer init()
29
From the following statements which is a drawback for Applet?
AIt works at client side so less response time
BMost of the web browsers support applets.
CIt can be executed by browsers running under many platforms, including Linux, Windows, and Mac Osetc.
DPlugin is required at client browser to execute applet
Correct Answer Plugin is required at client browser to execute applet
30
A ____ is the abstract foundation class for SWING's non-menu user interface controls?
AContainer
BJcomponent
CComponent
DPanel
Correct Answer Component
31
A ____ is the basic class for all SWING UI components?
AContainer
BJcomponent
CComponent
DJPanel
Correct Answer Jcomponent
32
An ____ is a change in the state of an item?
ASpinner
BEvent
COccurrence
DActivity
Correct Answer Event
33
Which of the following function is used to generate the application's top-level window?
AJPanel
BJFrame
CJCombo
DJWindow
Correct Answer JFrame
34
____ is a container for other components and is used to build bespoke panels for organizing and arranging components?
AJPanel
BJFrame
CJCombo
DJBox
Correct Answer JPanel
35
Which of the following component gives a drop-down list of options from which to choose?
AJPanel
BJButton
CJComboBox
DJBox
Correct Answer JComboBox
36
The ____ class serves as the foundation for all Swing components.
AJButton
BJComponent
CJTextField
DJPanel
Correct Answer JComponent
37
In _____________the components are platform independent?
AAWT
BSwing
CBoth
DNone of the above
Correct Answer Swing
38
An ____ is a java program that runs in a web browser.
AApplication
BAWT
CApplet
DJFrame
Correct Answer Applet
39
A ____ is a Swing framework component that offers a scroll bar that may be used to scroll content in a container.
AJScrollPanel
BJScrollBox
CJScroll
DJScrollBar
Correct Answer JScrollBar
40
The ____ function allows you to paint with a Graphics object.
AAllPaint()
BJpaint()
CRepaint()
Dpaint()
Correct Answer paint()
41
Which applet java.awt.component class provides the life cycle method?
Apublic void paint(Graphics g)
Bpublic void destroy()
Cpublic void stop()
Dpublic void init()
Correct Answer public void paint(Graphics g)
42
What invokes immediately after the start() method and also any time the applet needs to repaint itself in the browser?
Astop()
Binit()
Cpaint()
Ddestroy()
Correct Answer paint()
43
What is used to run an Applet?
AAn html file
BAn AppletViewer tool(for testing purpose)
CBoth A & B
DNone of the above
Correct Answer Both A & B
44
When an applet is terminated which of the following sequence of methods calls take place?
Astop(),paint(),destroy()
Bdestroy(),stop(),paint()
Cdestroy(),stop()
Dstop(),destroy()
Correct Answer stop(),destroy()

True / False

45 Is Applet and Application both are same in the swing framework? (Yes/No)
Correct Answer No
46 Applet works at client side so less response time. (True / False)?
Correct Answer True
47 The APPLET tag is used to start an applet from both an HTML document and from an applet viewer (True/False)?
Correct Answer True
48 All Applets must import java.applet and java.awt. (True/False)?
Correct Answer True
49 The APPLET tag is used to start an applet from both an HTML document and from an applet viewer (True/False)?
Correct Answer True
50 Applet runs inside the browser and does not work at client side (True/False)?
Correct Answer True
← Back to All MCQs