NEW
Font size
WorksheetsCC103 - FINAL SUMMATIVE
Total questions: 70
Worksheet time: 23mins
Which component creates a window in a Java Swing application?
JLabel
JButton
JFrame
JPanel
Which Swing component is used to display static text?
JTextField
JLabel
JCheckBox
JRadioButton
JTextField allows the user to:
Click buttons
Enter multi-line text
Choose from a list
Type a single line of text
Which component responds to user clicks?
JLabel
JTextField
JButton
JComboBox
Which component allows multiple options to be selected?
JLabel
JRadioButton
JCheckBox
JButton
JComboBox is best used for:
Entering text
Clicking actions
Selecting from a dropdown list
Displaying images
FlowLayout places components:
In a grid
In five regions
From left to right
Overlapping
BorderLayout divides the container into:
Three regions
Two columns
Five areas
One panel
What method sets the window's title?
setLabel()
setText()
setTitle()
setName()
Which method makes a JFrame visible?
setEnabled()
setVisible(true)
show()
display()
setResizable(false) will:
Hide the window
Make the window unresizable
Make it fullscreen
Set background color
Which method adds a component to a JFrame?
include()
setComponent()
add()
join()
JLabel(String text) creates:
An image
A button
A label with text
A combo box
The method to add a tooltip is:
setTipText()
setHintText()
setToolTipText()
setHelp()
JCheckBox(String, boolean) creates a checkbox with:
Image only
No label
Label and state
Text input
getText() on a JCheckBox returns:
Text label
State
Background color
Font size
What does isSelected() return?
Text
True/False
Integer
Font
To insert an item into a JComboBox:
addChoice()
setItem()
addItem()
append()
What component displays scrollbars?
JTextField
JScrollPane
JLabel
JButton
JScrollPane(Component) does what?
Sets color
Displays the given component with scrollbars
Adds a button
Creates a menu
JPanel is:
A scrollable area
A simple container
A text field
A label
JPanel can be initialized with:
Layout manager
Only integers
Images only
setText()
getContentPane() is used to:
Access label
Add components to JFrame
Show the tooltip
Exit window
What does the Color class help with?
Input
Events
Coloring components
Adding titles
setFont() is used to:
Display image
Set font style and size
Create layout
Resize window
GridLayout places components:
Overlapping
In rows and columns
On top of each other
In a circle
What component is not resizable by default?
JFrame
JLabel
JButton
JScrollPane
JButton(Action a) is used when:
Multiple buttons share the same behavior
Text is needed
ComboBox is needed
JLabel is used
What class controls component alignment in FlowLayout?
AlignmentManager
FlowStyle
FlowLayout constants
PanelManager
JTextField(int columns) creates:
A field with set column width
A combo box
A scroll area
An image holder
JComboBox is part of:
AWT
Swing
Console
JavaFX
Which method sets JButton text?
putText()
setText()
title()
updateLabel()
Which component can contain other components?
JButton
JLabel
JPanel
JTextField
setBounds(x, y, width, height) sets:
Font
Alignment
Window position and size
Text input
Font.PLAIN is a:
Color
Style
Title
Layout
JFrame(String title) creates a JFrame with:
No title
Specified title
A combo box
Nothing
JCheckBox has a square before:
Combo box
Label
Icon
Panel
JButton(String, Icon) combines:
Layout and font
Text and image
Window and frame
Text and dropdown
Icon is used for:
Text alignment
Fonts
Images
Titles
The default layout for JPanel is:
BorderLayout
GridLayout
FlowLayout
None
JLabel can use:
Text only
Icon only
Text and icon
Font only
A JFrame without setVisible(true) is:
Visible
Hidden
Resized
Styled
JTextField() creates:
Label
Empty text field
ScrollPane
Menu
JScrollPane(int, int) allows:
Font change
Scrollbar settings
Image view
Title update
getTitle() returns:
JLabel
JFrame title
Font style
Component size
JPanel(LayoutManager, boolean) lets you:
Set font
Set layout and buffering
Hide panel
Add JTextField
JCheckBox() creates:
A scroll area
Unlabeled checkbox
Combo box
Font field
setSelected(true) marks JCheckBox as:
Enabled
Visible
Selected
Resized
BorderLayout.CENTER adds a component to:
Top
Left
Middle
Bottom
Which of these classes adds component scrolling?
JPanel
JScrollPane
JTextField
JFrame
JLabel accepts user input.
True
False
JTextField allows multi-line input.
True
False
JComboBox allows typing text directly.
True
False
GridLayout aligns components with varying sizes.
True
False
JRadioButton allows selecting multiple options.
True
False
The setTitle() method can be used on a JLabel.
True
False
JScrollPane is used to hold buttons.
True
False
JPanel cannot contain other components.
True
False
JButton cannot contain both text and an image.
True
False
JCheckBox cannot be selected programmatically.
True
False
The setVisible() method is not required to display a JFrame.
True
False
You cannot use layout managers with JPanel.
True
False
JTextField(String, int) sets only the number of rows.
True
False
Font.PLAIN is used for italic text.
True
False
getContentPane() is used to add images only.
True
False
JFrame is a top-level container in Swing.
True
False
JButton can be clicked to trigger actions.
True
False
FlowLayout is the default layout for JPanel.
True
False
JCheckBox can be used to select multiple options.
True
False
The getText() method retrieves the text from a JTextField.
True
False
