0% found this document useful (0 votes)
28 views17 pages

Advance Java Button Jbutton, Check Box, Radio Button

Uploaded by

akhileshgawade10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views17 pages

Advance Java Button Jbutton, Check Box, Radio Button

Uploaded by

akhileshgawade10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

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) Only one will be selectable.


B) All will be selectable
independently.
C) They will not function.
D) It throws an exception.
7. Which of the following is not a method of JCheckBox?

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) Both buttons will be


selected
B) The previously selected
button will be deselected
C) Nothing happens
D) It throws an error
12. What method is used to disable a JButton?

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

You might also like