Sanjivani Rural Education Society’s
SANJIVANI K. B. P.
POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST:
AHMEDNAGAR
2024-2025
Class Test : [ Unit ll – Swing ] Date : / /2024
Name : Set : l
Roll no. :
1. Which package is used for Swing components in Java?
a) java.awt b) javax.swing c) java.util d) java.io
2. Which method is used to set the text of a JLabel in Swing?
a) setText() b) setTextLabel() c) setLabel() d) setTextValue()
3. How do you add components to a JFrame in Swing?
a) addComponent() method b) append() method c) insertComponent() method d) add() met
4. How do you make a Swing component visible on the screen?
a) setVisible(true) method b) show() method c) display() method d) open() method
5. The Components in JApplet are added to
a) Current JApplet Class b)ContentPane c)Both A and B d) None
6. How many Options can be selected in JRadioButton at a time?
a) Only One b) Multiple c)It is defined in the program d)Only a maximum of six
7. Frame class Entends Windows : a) True b) False.
8. Which is the container class?
a) Window b) Frame c) Dialog d)All of the above.
9. Swing is based on ____ architecture
a)Client server b)Model view controller c)Layered d)None of these
10. Which of the following is the top-level container in Swing?
a) JPanel b) JFrame c) JButton d) JLabel
11. Which component can be used to create a tabbed pane?
a) JTabbedPane b) JPaneTab c) JTabPane d) JTabbedPanel
12. Which method is used to set the alignment of text in a JLabel?
a) setAlignment() b) setTextAlign() c) setHorizontalAlignment() d) setLabelAlignment()
13. Which method is used to set the icon of a JButton?
a) setIcon() b) setButtonIcon() c) setImage() d) setGraphic()
14. MVC architecture is used by Applet?
a)True b)False
15. . Swing components are ______________ .
a)Platform dependent b)Platform independent c)Both A & B d)Platform oriented
16. The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons?
a) AbstractButton b) ButtonGroup c) JButton d) ImageIcon
17. In swing MVC architecture , C stands for ___________ .
a)Controller b)Container c)Class d)None of These
18. Default Orientation of progress bar is _________________ .
a)Horizontal b)Vertical c)Both A and B d)None of these
19. Which of the following architecture does the swing framework use ?
a) MVC b) MVP c) Layered Architecture d) Master-slave Architectur
20. What is the purpose of JTree?
a). To show data in the form of parent and child nodes. b). To show data in list view .
c)To show data in tabular form. d). To show d
21. . A tree represent a __________ view of data.
a) Structural b)Hierchical c)Multiple d) Singl
22. Which component displays following output?
a) JTable b) JTree
c) JToolTip d) None of the above
23. What is the default alignment of text in a JLabel?
a) Left b) Center c) Right d)Top
24. Which class is used to display an image in a Swing application?
a) JImage b) JImageIcon c) ImageComponent d) ImageIcon
25. A ____ is the basic class for all SWING UI components?
a)Container b) Jcomponent c)Component d)JButton
26. __________ is a Swing layout manager that arranges components in a row & a column.
a)BoxLayout b)GridLayout c)BorderLayout d)FlowLayout
27. Which swing components use ListSelectionModel
a) JTree and JTable b)JComboBox c) Jlist and Jtable d)JButton and JList
28. Which statements is missing in the given code below
import javax.swing.*;
public class FirstSwingExample
{ public static void main ( String [] args)
{ Jframe f =new Jframe();
Jbutton b = new Jbutton ("click") ;
a) f.setVisible(); b)import java.io.*;
b. setBounds( 130,100,100,40); c) f.SetVisible(true); d)f.getVisible(true);
f. add(b);
f.seSize(400,500);
f.setLayout (null); } }
29. Which package is used to add progress bar in an application?
a)javax.swing.JProgressBar b)javax.awt.JprogressBar c)java.JprogressBar d)javax.JprogressBar
30. Which Components are used in Following output?
a) JRadioButton ,JTextField b)JComboBox,JTextfield
c)JTextArea, JButton d)JTree, JLabel
31. Which component is display area for a short string of text, image or both?
a)Jbutton b)JLabel c)JTextfield d)JTextArea
32. To creat panel of borderlayout use_________
a)Jpanel p=new Jpanel(new BorderLayout()) b)Jpanel = new BorderLayout()
c)BorderLayout = new Jpanel(p) d)None of these
33. In Swing JButton class is derived from____
a)JToggledButton b)AbstractButton c)JComponent d)None of these
34. From following list Which is not Swing class?
a)JMenuItem b)JToolBar c)Jdailog d)JImageIcon
35. Which of these following is not a component of swing
a)JFrame b)JTree c)JList d)JButton
36. Which of the following swing components do not have an Icon parameter in its constructor?
a)JTextField b)JTextArea c)Both a and b d)none of these
37. Which of the following is not a constructor of JTree
a) JTree() b) JTree(int x) c)Both a and b d)None of these
38. Which of the following is not a swing class?
a)JSwing b)JList c)Both a and b d)None of these
39. Which method is used to close a swing frame?
a)setDefaultCloseOperation() b)Jclose() c)setClose() d)None of these
40. Which Swing component’s default layout manager arranges components in a top-to-bottom order?
a)JPanel b) JFrame c)JToolBar d) JScrollPane
41. What is the default horizontal alignment of text in a JLabel?
a)Center b)Left c)Right d)Justify
42. Which swing component is used for inputting a single line of text
a)JLabel b)JTextArea c)JTextField d)JButton
43. What method is used to add a component to a swing container
a)insert() b)append() c)appendComponent() d)add()
44. What method is used to set the text of a JLabel?
a)changeText() b)setText() c)modifyText() d)updateText()
45. Which method is used to enable or disable a JButton?
a)setActive() b)setEnabled() c)setClickable() d()setInteractive()
46. Which Swing component would you use to create a dropdown menu?
a)JComboBox b)JMenu c)JCheckBox d)JList
47. Which Swing class is used to create a dialog box?
a)JFrame b)JPanel c)JDailog d)JOptionPane
48. When adding a JComponent to a container, which of these methods is called by default?
a)insert() b)append() c)put() d)add()
49. Which method call will NOT affect the size of a JFrame?
a)pack() b)setPrefferedSize() c)setSize() d)setBounds()
50. Which component automatically updates its display when its Model changes?
a)JTable b)JList c)JComboBox d)JTextArea
51. Which method can be used to change the font of a JButton?
a)setFont() b) setTextFont() c) applyFont() d) changeFont()
52. In which method is the Graphics object provided for painting in Swing?
a)paint() b)render() c)paintComponent() d)draw()
53. What will JTable.getValueAt(row, col) return if the cell is empty?
a) "" b)null c)0 d)false
54. Which method is used to handle mouse clicks on a component?
a)mouseClicked() b)mouseEvent() c)mousePressed() d)mouseRelreased()
55. Which method should be used to remove all items from a JComboBox?
a)clear() b)reset() c)deleteAll() d)removeAllItems()
56. Which component is typically used to create a navigation bar in Swing?
a)JMenuBar b)JToolBar c)Jpanel d)JTrabbedPane
57. Which of the following is NOT a direct method to change a component’s foreground color?
a)setTextColor() b)setForeground c)setColor d)setPaintColor
58. What is the default layout manager of a JPanel?
a)FlowLayout b)GridLayout c)BorderLayout d)BoxLayout
59. Which method is used to make a JFrame visible?
a)show() b)display() c)setVisible() d)open()
60. What is the default behavior of JScrollPane when its viewport is empty?
a) Displays an empty scroll pane b)Shows a placeholder message.
c)Automatically hides itself. D) Throws an exception.
61. What happens if you call setText(null) on a JLabel?
a) The label is hidden. b)The label’s text is set to null.
c)The label throws an exception. d) The label displays an empty string.
62. JFrame is a subclass of JComponent.
a)True b)False