Sanjivani Rural Education Society’s
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2023-2024
Class Test: [Unit II - Swing] Date: / /2023
Name : Set: I
Roll No :
1.The following specifies the advantages of
It is lightweight.
It supports pluggable look and feel.
It follows MVC Architecture.
a) Swing b) AWT c) Both A & B d) None of the above
2.Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?
a) True b) False
3.The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons?
a) AbstractButton b) ButtonGroup c) JButton d) ImageIcon
4.The Java Foundation Classes is a set of GUI components which simplify the development of desktop applications?
a) True b) False
5.Which package is used for import the swing components?
a) java.swing b) java.awt c) javax.swing d) All of the above
6.The String parameter to JButton constructor __________.
a) tell which region to put the JButton in.
b) tells the color of the JButton.
c) tells what text will appear on JButton.
d) tells what should happen when JButton is pressed.
7.MVC architecture is _________
a) Modelling – Visual – Controller b) Model – View – Controller c) Model – Viewable – Controller d) Many – View – Controller
8.In swing, Buttons are subclasses of which class?
a) AbstractButton b) JButton c) Button d) JRadioButton
9.Which component is swing represents data in row and columns?
a) JTextArea b) JTable c) JPanel d) JtabbedPane
10.Which of the following is not constructor of JTree?
a) JTree(TreeNode tn) b) JTree(Vector v) c) JTree(int x) d) none of the above
11.____________class used to create node in tree.
a) TreeNode b) DefaultMutableNode c) DefaultMutableTreeNode d) Node
12.JTabbedPane class is present in which package?
a) java.awt b) java.swing c) java.awt.swing d) javax.swing
13.Which of the following method is not applicable for Button in swing.
a) setDiableIcon() b) setPressedIcon() c) setSelectedIcon() d) setRollOverIcon()
14.What is purpose of JTree?
a) To show data in form of parent and child nodes.
b) To show data in list view.
c) To show data in tabular form.
d) To show data in menu‐bar.
15.What is the use of : Container getContentPane()
a) Returns Container for a JDialog.
b) Returns a ContentPane for Menu
c) Returns a ContentPane for Applet
d) None of the above
16.Which of the following method is used to retrieve icon of JButton?
a) Icon getIcon() b) ImageIcon getImageIcon() c) ImageIcon getIcon() d) ImageIcon GetImageIcon()
17.From following list which is not Swing class?
a) JLabel b) JButton c) JImageIcon d) JCheckBox
18.Which component provides support for two‐state buttons?
a) Button, Checkbox b) JCheckBox,JRadioButton c) Button, MenuItem d) JCheckBox, TextField
19.In Swing, the content pane can be obtained via the method:
a) getContentPane() b) fetchContentPane() c) retrieveContent() d) accessContent()
20.In Swing, what component is used for adding hints to other Swing components to provide additional information?
A. JToolTip B. JLabel C. JTextField D. JTabbedPane
21.What is the purpose of a Swing JApplet?
A. To create a stand‐alone application.
B. To create a web applet.
C. To design GUI forms.
D. To handle database connections.
22.In the MVC architecture, what role does the "View" play?
A. Manages application data.
B. Represents the user interface and presentation logic.
C. Handles user input and interactions.
D. None of the above.
23.Which of the following is an advantage of Swing over AWT?
A. Native platform‐specific look and feel.
B. Heavier and slower components.
C. Lightweight and consistent look and feel.
D. None of the above.
24.Which Swing layout manager arranges components in a Square, with a specified number of rows and columns?
A. FlowLayout B. BorderLayout C. GridLayout D. CardLayout
25.In Swing, what is the purpose of a JMenuBar?
A. To create a main menu for the application.
B. To display tabbed panes.
C. To manage progress bars.
D. To handle keyboard input.
26.Which Swing component is used to display a single‐line input field with a hidden text for password entry?
A. JPasswordField B. JPasswordFieldBox C. JSecureInput D. JPasswordBox
27.Which of the following code snippets creates a Swing JButton correctly?
A) JButton button = new JButton("Click me");
B) Button button = new Button("Click me");
C) JComponent button = new JComponent("Click me");
D) Button button = new JButton("Click me");
28.Swing is a set of classes that provides more _____ and _____components than are possible with the AWT
a) Powerful , Flexible b) Great, Awesome c) Better , Powerful d) Stable, customizable
29.Swing components are not implemented by ____ code.
a) platform‐Specific b) Platform‐ independant c) Both d) none
30.Swing Components are ______ Weight
a) Light b) Moderate c) Heavy d)All of the Above
31.Super Class For Swing Buttons
a)AbstractButton b)Button c)Jbutton d)none
32.Which class encapsulates a mutually exclusive set of buttons.
a) MutualButtonGroup b) ButtonGroup c) JButtonGroup d) ButtonsGroup
33.Which class encapsulates an icon.
a) Image b) Icon c) IconImage d) ImageIcon
34.Which class represents the Swing version of Applet.
a) SwingApplet b) SApplet c) JApplet d) JSApplet
35.Which is Swing push button class.
a) JPushButton b) PushButton c) Jbutton d) None
36.Which is the Swing check box class.
a) JCheckbox b) JSCheckbox c) JCheckBox d) None
37.JApplet is ___ with functionality when compared with Applet
a) Rich b) poor c) Same d) different
38.The Swing version of a label.
a) SwingLabel b) Label c) Jlabel d) none
39.The method used to add components to a Container
a) add() b) Insert() c) addComponent d) InsertComponent
40.Which of the following method is not applicable for Button in swing.
a) setDiableIcon() b) setPressedIcon() c) setSelectedIcon() d) setRollOverIcon()
41.How will you assign the string and icon both to the JButton?
a) It is not possible
b) Use the setTextIcon( ) method
c) Use the setIconText( ) method
d) Initialize them directly in the constructor
42.Which event is generated when a JButton is pushed?
a) ItemEvent b) TextEvent c) PushEvent d) ActionEvent
43.How can we create Radio buttons in Swing?
a) Using ButtonGroup class b) Using JCheckboxGroup class c) Using JRadioButton class d) Using JButton class
44.Which of the following constants shows scroll bars always?
a) HORIZONTAL_SCROLLBAR_ALWAYS b) HORIZONTAL_SCROLLBAR_AS_NEEDED c) HORIZONTAL_SCROLLBARS
d) HORIZONTAL_ALWAYS
45.Tabs are added by calling
a) getTab() b) setTab() c) addTab() d) all of these
46.What will be the correct statement if you want a checkbox to be checked by default?
a) JCheckBox jc= new JCheckBox(String s, boolean checked)
b) JCheckBox jc= new JCheckBox(String s, boolean false)
c) JCheckBox jc= new JCheckBox(String s, boolean unchecked)
d) JCheckBox jc= new JCheckBox(String s, boolean true)
47.Which is the correct syntax for constructor of JRadioButton?
a) JRadioButton(Icon i, String s, boolean state)
b) JRadioButton(String s, Icon i, boolean state)
c) JRadioButton(Icon i,boolean state, String s, )
d) d)JRadioButton(boolean state, String s, Icon i)
48.Is it possible to add array of objects to trees? How?
a) Not possible
b) Yes, using its one of the forms of constructor
c) Yes, using the add( ) method
d) Yes, using the addItem( ) method
49.________ is a component that displays rows and columns of data.
a) JPanel b) JFrame c) JTable d) None of these
50.Which method is used to add the tabs in the tabbed pane?
a) add( ) b) addItem( ) c) addPane( ) d) addTab( )
52.The _____________ determines how the component reacts to the user
a) View b) Controller c) User d) Model
53.Identify The Error :
import javax.swing.*;
public class FirstSwingExample{
public static void main(String[] args) {
JFrame f=new JFrame();
JButton b=new JButton("click");
b.setBounds(130,100,100, 40)
f.add(b);
f.setSize(400,500);
f.setLayout(null);
}
}
A) No Error B) Set Visible Method is not defined C) Button is not added on Frame D) inside main method error