Advance Java Button Jbutton, Check Box, Radio Button
Advance Java Button Jbutton, Check Box, Radio Button
by Akhilesh Gawade
1. What class is used to create buttons in Java Swing?
A) Button
B) JButton
C) ButtonGroup
D) JPanel
2. What method is used to add an action listener to a
JButton?
A) addButtonListener()
B) addActionListener()
C) setActionListener()
D) addListener()
3. Which of the following constructors is valid for
creating a JButton?
A) new JButton()
B) new JButton(String text)
C) new JButton(Icon icon)
D) All of the above
4. Which of these methods is used to change the text on a
JButton after it has been created?
A) setText()
B) setLabel()
C) changeText()
D) updateText()
5. To group multiple JRadioButtons together so only one
can be selected at a time, which class is used?
A) ButtonGroup
B) JPanel
C) ButtonModel
D) JCheckBox
6. What will happen if multiple JRadioButtons are added to
a panel without grouping them in a ButtonGroup?
A) isSelected()
B) setSelected()
C) setCheckBox()
D) getText()
8. What is the purpose of the JCheckBox class in Java?
A) To allow multiple
selections in a group
B) To create mutually
exclusive selections
C) To display a checkable
box
D) None of the above
9. Which method is used to determine if a JCheckBox is
currently checked?
A) isSelected()
B) getCheck()
C) isChecked()
D) getSelected()
10. Can JCheckBox be used in combination with
JRadioButtons in a single ButtonGroup?
A) Yes, always
B) No, they are mutually exclusive
C) Yes, but it is not recommended
D) No, JCheckBox and JRadioButton
work independently
11. What happens when you select a different JRadioButton in a
ButtonGroup?
A) setEnabled(false)
B) disableButton()
C) disable()
D) setDisabled(true)
13. What method is used to check if a JButton is enabled?
A) isActive()
B) isEnabled()
C) isOn()
D) isWorking()
14. In which package can you find JButton, JCheckBox, and
JRadioButton classes?
A) java.awt
B) javax.swing
C) java.io
D) javax.awt
15. To arrange JRadioButtons vertically in a panel, which
layout manager would you likely use?
A) BorderLayout
B) GridLayout
C) FlowLayout
D) BoxLayout
you
ank
th