Home »
MCQs
Java Swing Multiple-Choice Questions (MCQs)
Swing is a GUI widget toolkit for Java. It is part of Oracle's Java Foundation Classes – an API for providing a graphical user interface for Java programs.
Java Swing MCQs: This section contains multiple-choice questions and answers on the various topics of Java Swing. Practice these MCQs to test and enhance your skills on Java Swing.
List of Java Swing MCQs
1. Which of the following architecture does the Swing framework use?
- MVC
- MVP
- Layered architecture
- Master-Slave architecture
Answer: A) MVC
Explanation:
Swing framework uses MVC architecture.
Discuss this Question
2. Which language is used in the swing framework?
- JavaScript
- Java
- React
- Python
Answer: B) Java
Explanation:
The swing framework is written in the Java programming language.
Discuss this Question
3. A ____ is the abstract foundation class for SWING's non-menu user interface controls?
- Container
- Jcomponent
- Component
Answer: C) Component
Explanation:
A Component is the abstract foundation class for SWING's non-menu user interface controls.
Discuss this Question
4. A ____ is the basic class for all SWING UI components?
- Container
- Jcomponent
- Component
Answer: B) Jcomponent
Explanation:
A JComponent is a basic class for all SWING UI components.
Discuss this Question
5. A ____ is a one-line input field that allows the user to choose a number or an object value from an ordered sequence?
- JTextarea
- Jtextfield
- Jspinner
- Jslider
Answer: C) Jspinner
Explanation:
A JSpinner is a one-line input field that allows the user to choose a number or an object value from an ordered sequence.
Discuss this Question
6. A ____ control is a dialogue window that allows the user to pick a file?
- JChoosFile
- JFilefield
- JFile
- JFileChooser
Answer: D) JFileChooser
Explanation:
A JFileChooser control is a dialogue window that allows the user to pick a file.
Discuss this Question
7. An ____ is a change in the state of an item?
- Spinner
- Event
- Occurrence
- Activity
Answer: B) Event
Explanation:
An event is a change in the state of an item.
Discuss this Question
8. How many types of events are there?
- 5
- 3
- 2
- 4
Answer: C) 2
Explanation:
There are two types of events: foreground events and background events.
Discuss this Question
9. Which of the following type of events requires direct interaction with the user?
- Foreground events
- Background events
Answer: A) Foreground events
Explanation:
Foreground events require direct interaction with the user.
Discuss this Question
10. Which of the following type of events requires direct interaction with the end-user?
- Foreground events
- Background events
Answer: B) Background events
Explanation:
Background events require direct interaction with the end-user.
Discuss this Question
11. To manage events, Java employs the ____?
- Custom-based Event Model
- Retired Event Model
- Delegation Event Model
Answer: C) Delegation Event Model
Explanation:
To manage events, Java employs the Delegation Event Model.
Discuss this Question
12. Which of the following function is used to generate the application's top-level window?
- JPanel
- JFrame
- JCombo
Answer: B) JFrame
Explanation:
JFrame is used to generate the application's top-level window.
Discuss this Question
13. ____ is a container for other components and is used to build bespoke panels for organizing and arranging components?
- JPanel
- JFrame
- JCombo
- JBox
Answer: A) JPanel
Explanation:
JPanel is a container for other components and is used to build bespoke panels for organizing and arranging components.
Discuss this Question
14. Which of the following component gives a drop-down list of options from which to choose?
- JPanel
- JButton
- JComboBox
- JBox
Answer: C) JComboBox
Explanation:
JComboBox component gives a drop-down list of options from which to choose.
Discuss this Question
15. ____ are classes that act as a connection point between event listeners and event sources?
- Event adapters
- Events Handler
- Event listener
- Jevent
Answer: A) Event adapters
Explanation:
Event adapters are classes that act as a connection point between event listeners and event sources.
Discuss this Question
16. The ____ class serves as the foundation for all Swing components.
- JButton
- JComponent
- JTextField
Answer: B) JComponent
Explanation:
The JComponent class serves as the foundation for all Swing components.
Discuss this Question
17. In Swing, the ____ is used to render visuals and listen for events?
- Event adapters
- Events Handler
- Event listener
- Event-Driven Thread
Answer: D) Event-Driven Thread
Explanation:
In Swing, the Event-Driven Thread is used to render visuals and listen for events.
Discuss this Question
18. Among AWT and Swing which is platform independent?
- AWT
- Swing
Answer: B) Swing
Explanation:
Swing framework is platform independent whereas AWT is platform dependent.
Discuss this Question
19. Swing framework is ____ component?
- Heavyweight
- Lightweight
Answer: B) Lightweight
Explanation:
Swing framework is a lightweight component.
Discuss this Question
20. The ____ class enables the development of abstract functions as well as action interfaces.
- Action
- Abstraction
- AbstractionAction
Answer: C) AbstractionAction
Explanation:
The AbstractAction class enables the development of abstract functions as well as action interfaces.
Discuss this Question
21. ____ is a data transfer class that provides an easy way to transport data from the Jcomponent.
- DataShare
- Transfer
- DataTransfer
- TransferHandler
Answer: D) TransferHandler
Explanation:
TransferHandler is a data transfer class that provides an easy way to transport data from the Jcomponent.
Discuss this Question
22. invokeandwait() method in Swing framework is ____.
- Synchronous
- Asynchronous
Answer: A) Synchronous
Explanation:
invokeandwait() method in the Swing framework is Synchronous.
Discuss this Question
23. invokelater() method in Swing framework is ____?
- Synchronous
- Asynchronous
Answer: B) Asynchronous
Explanation:
invokelater() method in the Swing framework is Asynchronous.
Discuss this Question
24. An ____ is a short software that runs in a web browser.
- Application
- AWT
- Applet
- JFrame
Answer: C) Applet
Explanation:
An applet is a short software that runs in a web browser.
Discuss this Question
25. Is Applet and Application both are same in the swing framework?
- Yes
- No
Answer: B) No
Explanation:
An application and an applet are two sorts of Java programs with distinct features that execute in separate settings.
Discuss this Question
26. The act of turning the state of a Swing component or set of components into a stream of bytes that can be saved to a file or transferred over a network is referred to as ____ in Swing.
- serialisation
- Accessibility
- Localization
- Globalization
Answer: A) serialisation
Explanation:
The act of turning the state of a Swing component or set of components into a stream of bytes that can be saved to a file or transferred over a network is referred to as serialization in Swing.
Discuss this Question
27. A ____ is a Swing framework component that offers a scroll bar that may be used to scroll content in a container.
- JScrollPanel
- JScrollBox
- JScroll
- JScrollBar
Answer: D) JScrollBar
Explanation:
A JScrollBar is a Swing framework component that offers a scroll bar that may be used to scroll content in a container.
Discuss this Question
28. A ____ is a container that provides a viewport for showing a piece of a bigger component.
- JScrollPanel
- JScrollBox
- JScroll
- JScrollPane
Answer: D) JScrollPane
Explanation:
A JScrollPane is a container that provides a viewport for showing a piece of a bigger component.
Discuss this Question
29. EDT in Swing framework stands for ____.
- Event Driven thread
- Event Determined Thread
- Electronic-event-driven thread
Answer: A) Event Driven thread
Explanation:
EDT stands for Event-driven thread.
Discuss this Question
30. A ____ is a type of object that organizes components in a container.
- Event adapter
- Event Handler
- layout manager
- Grid Manager
Answer: C) layout manager
Explanation:
A layout manager is a type of object that organizes components in a container.
Discuss this Question
31. The ____ function allows you to paint with a Graphics object.
- AllPaint()
- Jpaint()
- Repaint()
- paint()
Answer: D) paint()
Explanation:
The paint() function allows you to paint with a Graphics object.
Discuss this Question
32. Is Swing thread-safe?
- Yes
- No
Answer: B) No
Explanation:
No, Swing framework is not thread-safe.
Discuss this Question
33. The ____ function is used to specify the layout of a container.
- UseLayeout()
- setLayout()
- layout()
- DesignLayout()
Answer: B) setLayout()
Explanation:
The setLayout() function is used to specify the layout of a container.
Discuss this Question
34. ____ method validates the components of a container.
- Validate()
- Examine()
- Analyze()
Answer: A) Validate()
Explanation:
Validate() method validates the components of a container.
Discuss this Question
35. Which of the following companies are using swing framework?
- IBM
- Oracle
- Microsoft
- All of the above
Answer: D) All of the above
Explanation:
Following companies are using swing framework:
Discuss this Question