Advanced GUI Programming Practice Quiz
- Which of the following is an event-driven programming language used for GUI development?
- A) Python
- B) Java
- C) C++
- D) All of the above
Answer: D) All of the above
- In Java, which class is used to create a window in a GUI application?
- A) JFrame
- B) Window
- C) Applet
- D) JButton
Answer: A) JFrame
- What does the event handling process in GUI programming involve?
- A) Handling user input via events like clicks and keystrokes
- B) Writing the GUI layout code
- C) Running the application in debug mode
- D) Writing backend logic
Answer: A) Handling user input via events like clicks and keystrokes
- Which layout manager is used in Java Swing to arrange components in rows and columns?
- A) FlowLayout
- B) BorderLayout
- C) GridLayout
- D) CardLayout
Answer: C) GridLayout
- In Python’s Tkinter, which widget is used to create a button?
- A) TkButton
- B) ButtonWidget
- C) TkinterButton
- D) Button
Answer: A) TkButton
- What is the primary purpose of the event listener in GUI programming?
- A) To display content on the window
- B) To perform actions when user interactions occur
- C) To create the window’s background color
- D) To update the content at regular intervals
Answer: B) To perform actions when user interactions occur
- Which of the following is a common layout manager in Java’s Swing for organizing components?
- A) GridBagLayout
- B) FlowLayout
- C) BorderLayout
- D) All of the above
Answer: D) All of the above
- Which method is used to make a Java JFrame visible?
- A) setVisible(true)
- B) show(true)
- C) display()
- D) visible()
Answer: A) setVisible(true)
- Which Python library is commonly used for GUI applications?
- A) Tkinter
- B) PyQt
- C) wxPython
- D) All of the above
Answer: D) All of the above
- In a GUI application, which of the following is NOT an event source?
- A) Button
- B) TextBox
- C) Mouse
- D) DataBase
Answer: D) DataBase
- Which of the following is the correct syntax for creating a button in Java Swing?
- A) JButton(“Click Me”);
- B) new JButton(“Click Me”);
- C) Button(“Click Me”);
- D) new Button(“Click Me”);
Answer: B) new JButton(“Click Me”);
- In the context of GUI, what does MVC stand for?
- A) Model-View-Controller
- B) Mouse-View-Controller
- C) Model-View-Creator
- D) Main-View-Controller
Answer: A) Model-View-Controller
- Which layout manager in Java places components at the top, bottom, left, right, and center of a container?
- A) GridLayout
- B) BorderLayout
- C) FlowLayout
- D) GridBagLayout
Answer: B) BorderLayout
- In Python’s Tkinter, which method is used to start the event loop?
- A) root.mainloop()
- B) startLoop()
- C) eventLoop()
- D) loop.start()
Answer: A) root.mainloop()
- In Java, which package is primarily used for creating GUIs?
- A) java.util
- B) java.swing
- C) java.awt
- D) java.gui
Answer: C) java.awt
- Which widget in Tkinter allows the user to enter text?
- A) Entry
- B) Label
- C) Button
- D) TextBox
Answer: A) Entry
- Which function is used to add a component to a container in Java’s Swing?
- A) addComponent()
- B) addComponentToContainer()
- C) add()
- D) insert()
Answer: C) add()
- What is the purpose of a canvas widget in Tkinter?
- A) To display images
- B) To draw shapes and graphics
- C) To input text
- D) To handle mouse events
Answer: B) To draw shapes and graphics
- Which of the following is an event handler for mouse events in Java Swing?
- A) MouseListener
- B) MouseEventHandler
- C) KeyListener
- D) ActionEvent
Answer: A) MouseListener
- What does the method setPreferredSize() do in Java’s Swing?
- A) It sets the size of the window
- B) It sets the preferred size of a component
- C) It resizes the window to the preferred size
- D) It sets the preferred layout of a container
Answer: B) It sets the preferred size of a component
- Which function is used to remove a widget in Tkinter?
- A) remove()
- B) delete()
- C) destroy()
- D) exit()
Answer: C) destroy()
- In Java, which method is used to retrieve the text from a JTextField?
- A) getText()
- B) getTextValue()
- C) getString()
- D) getValue()
Answer: A) getText()
- What is the primary function of the ActionListener in Java?
- A) To listen for mouse events
- B) To listen for keyboard events
- C) To perform actions when a button is clicked
- D) To handle resizing of windows
Answer: C) To perform actions when a button is clicked
- In GUI programming, which of the following is typically used to handle keyboard input?
- A) KeyListener
- B) MouseListener
- C) ActionListener
- D) WindowListener
Answer: A) KeyListener
- In Java, what is the default layout manager for a JFrame?
- A) FlowLayout
- B) BorderLayout
- C) GridLayout
- D) GridBagLayout
Answer: B) BorderLayout
- Which of the following is used in Java Swing to create a simple text label?
- A) JLabel
- B) JTextField
- C) JTextArea
- D) JLabelText
Answer: A) JLabel
- In Tkinter, which widget is used for creating a dropdown menu?
- A) OptionMenu
- B) DropdownMenu
- C) Menu
- D) ComboBox
Answer: A) OptionMenu
- Which event listener is used to handle window closing events in Java Swing?
- A) WindowListener
- B) ActionListener
- C) MouseListener
- D) KeyListener
Answer: A) WindowListener
- In Java, which class is used to display text areas that can be edited?
- A) JTextField
- B) JTextArea
- C) JText
- D) JTextEditor
Answer: B) JTextArea
- What is the purpose of a JPanel in Java Swing?
- A) To display images
- B) To hold multiple components and layout them
- C) To display a menu
- D) To create a text field
Answer: B) To hold multiple components and layout them
- In Java Swing, which of the following is used to create a radio button?
- A) JRadioButton
- B) RadioButton
- C) JButton
- D) JCheckBox
Answer: A) JRadioButton
- In Tkinter, which widget is used to create a scrollable text area?
- A) Text
- B) Entry
- C) Canvas
- D) Scrollbar
Answer: A) Text
- In Java Swing, which class is used to create a checkbox?
- A) JCheckBox
- B) JCheckMark
- C) ButtonGroup
- D) JRadioButton
Answer: A) JCheckBox
- Which layout manager in Java arranges components sequentially, from top to bottom or left to right?
- A) BorderLayout
- B) FlowLayout
- C) GridBagLayout
- D) GridLayout
Answer: B) FlowLayout
- In Tkinter, which method is used to configure a widget’s options (like text, color)?
- A) set()
- B) config()
- C) options()
- D) configure()
Answer: B) config()
- What is the purpose of JTabbedPane in Java Swing?
- A) To arrange components in a table format
- B) To add tabs to a GUI for organizing multiple panels
- C) To create a toolbar
- D) To create a dialog box
Answer: B) To add tabs to a GUI for organizing multiple panels
- What is the purpose of the pack() method in Java Swing?
- A) To adjust the component size
- B) To set the window’s layout
- C) To fit components within a container
- D) To add components to a container
Answer: C) To fit components within a container
- Which of the following is used to create a dialog box in Java Swing?
- A) JDialog
- B) JOptionPane
- C) DialogBox
- D) MessageBox
Answer: B) JOptionPane
- In Python’s Tkinter, what is the method used to create a top-level window?
- A) Tk()
- B) Toplevel()
- C) Window()
- D) Top()
Answer: B) Toplevel()
- Which event listener is used in Java to handle actions from buttons, menus, and other interactive components?
- A) MouseListener
- B) KeyListener
- C) ActionListener
- D) WindowListener
Answer: C) ActionListener
- In Java Swing, which method is used to set the icon for a JFrame window?
- A) setIconImage()
- B) setWindowIcon()
- C) setImageIcon()
- D) setIcon()
Answer: A) setIconImage()
- In Tkinter, which method is used to obtain the current value of a widget like a button or text field?
- A) get()
- B) fetch()
- C) value()
- D) retrieve()
Answer: A) get()
- In Java, which method is used to add a component to a container with a specific position (for example, left or center)?
- A) setComponent()
- B) addComponent()
- C) add()
- D) set()
Answer: C) add()
- In Java, what is the function of the CardLayout manager?
- A) To stack components on top of each other
- B) To arrange components in a grid
- C) To create a tabbed layout
- D) To arrange components in a row or column
Answer: A) To stack components on top of each other
- Which class in Java Swing is used to create a menu bar?
- A) JMenu
- B) JMenuBar
- C) JMenuItem
- D) JMenuButton
Answer: B) JMenuBar
- In Tkinter, which widget is used to display images?
- A) Image
- B) Label
- C) Canvas
- D) PhotoImage
Answer: D) PhotoImage
- What is the function of the GridBagLayout in Java?
- A) To arrange components in equal size rows and columns
- B) To create a flexible layout with varying column and row sizes
- C) To manage components in a simple grid-like structure
- D) To arrange components in a single row or column
Answer: B) To create a flexible layout with varying column and row sizes
- In Tkinter, which widget is used for displaying a list of items from which a user can choose?
- A) Listbox
- B) Combobox
- C) OptionMenu
- D) TextBox
Answer: A) Listbox
- What is the default layout manager in Java’s JPanel?
- A) GridBagLayout
- B) FlowLayout
- C) BorderLayout
- D) GridLayout
Answer: B) FlowLayout
- In Java Swing, what is used to detect the mouse events such as clicks and movements?
- A) MouseAdapter
- B) MouseListener
- C) MouseMotionListener
- D) MouseEvent
Answer: B) MouseListener
- Which class in Java Swing is used to create a slider component?
- A) JSlider
- B) JScrollbar
- C) JProgressBar
- D) JTextArea
Answer: A) JSlider
- In Python Tkinter, which method is used to delete all items in a Listbox widget?
- A) delete(0, END)
- B) clear()
- C) removeAll()
- D) deleteAll()
Answer: A) delete(0, END)
- In Java Swing, which method is used to create a button with an icon?
- A) new JButton(Icon)
- B) JButton(“Label”, Icon)
- C) JButton.setIcon(Icon)
- D) new JButton(Icon, Label)
Answer: B) JButton(“Label”, Icon)
- What does the JSpinner class do in Java?
- A) Creates a text field
- B) Allows the user to select a number or value from a range
- C) Creates a drop-down list
- D) Displays an image
Answer: B) Allows the user to select a number or value from a range
- Which method in Tkinter is used to exit a window?
- A) exit()
- B) quit()
- C) stop()
- D) close()
Answer: B) quit()
- Which method in Java Swing is used to refresh a GUI after changes?
- A) refresh()
- B) update()
- C) repaint()
- D) refreshDisplay()
Answer: C) repaint()
- In Python’s Tkinter, which widget allows you to display multiple lines of text with scrollbars?
- A) Text
- B) Label
- C) Listbox
- D) Entry
Answer: A) Text
- Which Java class is used to create a combo box (drop-down list)?
- A) JComboBox
- B) JList
- C) JRadioButton
- D) JTextField
Answer: A) JComboBox
- In Java Swing, which of the following is used to create a tree structure?
- A) JTree
- B) JTable
- C) JList
- D) JLabel
Answer: A) JTree
- In Tkinter, which widget is used to display a simple static text label?
- A) Label
- B) Text
- C) Entry
- D) Button
Answer: A) Label
- In Java Swing, which method is used to set the background color of a component?
- A) setBackgroundColor()
- B) setBackground()
- C) setColor()
- D) setColorBackground()
Answer: B) setBackground()
- Which of the following layout managers in Java arranges components in a grid with equal-width columns and equal-height rows?
- A) GridLayout
- B) FlowLayout
- C) BorderLayout
- D) CardLayout
Answer: A) GridLayout
- In Tkinter, which widget is used to create a single-line text input field?
- A) Label
- B) Text
- C) Entry
- D) Button
Answer: C) Entry
- Which of the following events is handled by the WindowListener in Java Swing?
- A) Button clicks
- B) Window opening, closing, or resizing
- C) Key presses
- D) Mouse movements
Answer: B) Window opening, closing, or resizing
- In Java Swing, which of the following is used to handle user input for date selection?
- A) JDateChooser
- B) JCalendar
- C) JDatePicker
- D) JTextField
Answer: A) JDateChooser
- In Python’s Tkinter, how can you set the font size of a widget text?
- A) font_size()
- B) font()
- C) set_font()
- D) configure(font=(“Arial”, 12))
Answer: D) configure(font=(“Arial”, 12))
- What method in Java Swing is used to enable or disable a button?
- A) setEnabled()
- B) setVisible()
- C) setActive()
- D) setButtonState()
Answer: A) setEnabled()
- In Tkinter, which widget is used to create a drop-down list?
- A) Listbox
- B) Combobox
- C) Text
- D) OptionMenu
Answer: B) Combobox
- What is the purpose of the setPreferredSize() method in Java?
- A) To define the component’s width and height
- B) To set a minimum size
- C) To set the size of the component according to the parent container
- D) To set a maximum size for the component
Answer: A) To define the component’s width and height
- In Java, which layout manager arranges components in a row, with the components filling the available space in equal proportions?
- A) BorderLayout
- B) FlowLayout
- C) GridLayout
- D) BoxLayout
Answer: D) BoxLayout
- Which of the following is the correct way to create a frame window in Java Swing?
- A) JFrame window = new JFrame();
- B) Window window = new JFrame();
- C) JFrame frame = new Window();
- D) new JFrame(“Window”);
Answer: A) JFrame window = new JFrame();
- In Java Swing, which component is used to create a horizontal or vertical slider?
- A) JSpinner
- B) JProgressBar
- C) JSlider
- D) JButton
Answer: C) JSlider
- Which widget in Tkinter is used to draw graphics, such as lines, shapes, and text?
- A) Canvas
- B) Frame
- C) Text
- D) Label
Answer: A) Canvas
- In Java, which of the following is the default layout manager for a JFrame?
- A) BorderLayout
- B) FlowLayout
- C) GridLayout
- D) CardLayout
Answer: A) BorderLayout
- What does the pack() method do in Java Swing?
- A) It arranges components in the container using the default layout manager.
- B) It resizes components according to the screen size.
- C) It sets the size of the frame to fit the components inside.
- D) It adds components to the container.
Answer: C) It sets the size of the frame to fit the components inside.
- In Tkinter, which widget can display multiple lines of text and allows users to edit it?
- A) Text
- B) Label
- C) Entry
- D) Button
Answer: A) Text
- In Java, which method is used to remove a component from a container?
- A) removeComponent()
- B) remove()
- C) delete()
- D) clear()
Answer: B) remove()
- Which of the following methods is used to display a modal dialog in Java Swing?
- A) setDialogVisible()
- B) showDialog()
- C) JOptionPane.showConfirmDialog()
- D) JDialog.showDialog()
Answer: C) JOptionPane.showConfirmDialog()
- What is the primary purpose of the JLabel component in Java Swing?
- A) To create a button
- B) To display text or an image
- C) To create a text field for user input
- D) To create a checkbox
Answer: B) To display text or an image
- Which of the following methods in Tkinter is used to update the value of a variable associated with a widget?
- A) update()
- B) set()
- C) change()
- D) value()
Answer: B) set()
- In Java, which layout manager arranges components based on a series of rows and columns, where each cell can contain a component?
- A) GridLayout
- B) BoxLayout
- C) FlowLayout
- D) BorderLayout
Answer: A) GridLayout
- In Java Swing, which component is used to create a progress bar?
- A) JProgressBar
- B) JSlider
- C) JSpinner
- D) JLabel
Answer: A) JProgressBar
- Which Tkinter widget is used for creating a radio button (single-choice button)?
- A) Checkbutton
- B) Radiobutton
- C) Button
- D) Label
Answer: B) Radiobutton
- In Java Swing, which component is used to display a menu?
- A) JMenuBar
- B) JMenu
- C) JMenuItem
- D) JToolBar
Answer: A) JMenuBar
- In Java Swing, which of the following is used to create a vertical or horizontal divider between components?
- A) JSplitPane
- B) JSeparator
- C) JDivider
- D) JPanel
Answer: A) JSplitPane
- In Python’s Tkinter, how do you set the width of a widget?
- A) width(value)
- B) setWidth(value)
- C) configure(width=value)
- D) set_size(width=value)
Answer: C) configure(width=value)
- In Java Swing, what component is used to display a multi-line text area?
- A) JTextField
- B) JTextArea
- C) JLabel
- D) JTextPane
Answer: B) JTextArea
- In Tkinter, which widget is used to create a button that the user can press to perform an action?
- A) Button
- B) Entry
- C) Label
- D) Text
Answer: A) Button
- In Java, which class is used to create a panel within a frame to group components together?
- A) JPanel
- B) JFrame
- C) JContainer
- D) JFramePanel
Answer: A) JPanel
- Which of the following methods is used to close a JFrame window in Java?
- A) closeWindow()
- B) setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
- C) stopWindow()
- D) close()
Answer: B) setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
- Which layout manager in Java Swing is used to arrange components from left to right in a single row?
- A) GridLayout
- B) FlowLayout
- C) BoxLayout
- D) BorderLayout
Answer: B) FlowLayout
- In Tkinter, which widget is used to display a list of selectable items?
- A) Button
- B) Listbox
- C) Radiobutton
- D) Combobox
Answer: B) Listbox
- In Java Swing, what is the primary function of the JTabbedPane component?
- A) To display menus
- B) To allow multiple panels to be displayed in tabs
- C) To create a progress bar
- D) To display images
Answer: B) To allow multiple panels to be displayed in tabs
- In Java Swing, which component is used to display images or icons?
- A) JLabel
- B) JTextArea
- C) JButton
- D) JImageLabel
Answer: A) JLabel
- In Tkinter, which method is used to get the current value of a widget variable?
- A) get_value()
- B) value()
- C) retrieve()
- D) get()
Answer: D) get()
- In Java Swing, which method is used to make a component visible or invisible?
- A) setVisible()
- B) showComponent()
- C) hideComponent()
- D) setInvisible()
Answer: A) setVisible()
- Which of the following is a default layout manager for a JPanel in Java?
- A) BorderLayout
- B) GridLayout
- C) FlowLayout
- D) CardLayout
Answer: C) FlowLayout
- What method in Java is used to set the text of a JButton?
- A) setButtonText()
- B) setText()
- C) changeText()
- D) updateText()
Answer: B) setText()
- In Java Swing, which class is used to create a dialog box for displaying information to the user?
- A) JDialog
- B) JOptionPane
- C) JFrame
- D) JPopupMenu
Answer: B) JOptionPane
- In Tkinter, which widget is used for creating a checkbox that can be checked or unchecked?
- A) Radiobutton
- B) Checkbutton
- C) Button
- D) Label
Answer: B) Checkbutton
- Which Java Swing component is used to display an input field where users can enter a single line of text?
- A) JTextArea
- B) JTextField
- C) JPasswordField
- D) JTextBox
Answer: B) JTextField
- In Tkinter, which widget is used to create a button that performs an action when clicked?
- A) Entry
- B) Radiobutton
- C) Button
- D) Label
Answer: C) Button
- Which Java Swing component is used to display a list of items, allowing a user to select one or more items?
- A) JComboBox
- B) JList
- C) JCheckbox
- D) JMenu
Answer: B) JList
- In Tkinter, which widget is used to create a scrollable text field for multiple lines of text?
- A) Entry
- B) Text
- C) Listbox
- D) Label
Answer: B) Text
- In Java Swing, what method is used to change the text color of a component?
- A) setColor()
- B) setForeground()
- C) setTextColor()
- D) changeColor()
Answer: B) setForeground()
- In Tkinter, which widget is used to create a drop-down menu with multiple options?
- A) Listbox
- B) Combobox
- C) Radiobutton
- D) OptionMenu
Answer: D) OptionMenu
- What is the purpose of the setLayout() method in Java Swing?
- A) To add components to the container
- B) To define how components should be arranged in the container
- C) To set the background color of the container
- D) To set the visibility of the container
Answer: B) To define how components should be arranged in the container
- Which of the following layout managers in Java arranges components according to their size and preferred position?
- A) GridLayout
- B) BorderLayout
- C) FlowLayout
- D) CardLayout
Answer: C) FlowLayout
- In Java Swing, which component is used to create a menu bar with dropdown menus?
- A) JMenuBar
- B) JMenu
- C) JMenuItem
- D) JToolBar
Answer: A) JMenuBar
- In Java Swing, which method is used to make a dialog box visible?
- A) showDialog()
- B) setVisible(true)
- C) display()
- D) show()
Answer: B) setVisible(true)
- In Tkinter, which widget is used to display an image?
- A) Image
- B) PictureBox
- C) Label
- D) Canvas
Answer: C) Label
- In Java Swing, which class is used to create a pop-up menu that can be attached to a component?
- A) JPopupMenu
- B) JContextMenu
- C) JMenu
- D) JMenuBar
Answer: A) JPopupMenu
- In Tkinter, which method is used to place widgets within a window?
- A) pack()
- B) place()
- C) grid()
- D) All of the above
Answer: D) All of the above
- In Java, which of the following is used to manage a layout in a JPanel?
- A) LayoutManager
- B) BorderLayout
- C) GridBagLayout
- D) All of the above
Answer: D) All of the above
- In Java Swing, which component is used to create a file chooser for selecting files or directories?
- A) JFileChooser
- B) JFileSelect
- C) JFileDialog
- D) JFile
Answer: A) JFileChooser
- In Tkinter, which of the following is used to display a message box?
- A) messagebox
- B) DialogBox
- C) MsgBox
- D) infoBox
Answer: A) messagebox
- In Java, which method is used to close a window when the close button is clicked?
- A) dispose()
- B) exit()
- C) close()
- D) setVisible(false)
Answer: A) dispose()
- In Java Swing, which layout manager is used for placing components at the top, bottom, left, right, or center of a container?
- A) FlowLayout
- B) BoxLayout
- C) BorderLayout
- D) GridLayout
Answer: C) BorderLayout
- In Tkinter, which method is used to display an image within a Canvas widget?
- A) create_image()
- B) insert_image()
- C) add_image()
- D) draw_image()
Answer: A) create_image()
- Which of the following methods in Java Swing is used to add a component to a container?
- A) addComponent()
- B) add()
- C) insert()
- D) put()
Answer: B) add()
- In Java Swing, which class is used to create a toolbar with buttons for common actions?
- A) JToolBar
- B) JButton
- C) JMenuBar
- D) JPanel
Answer: A) JToolBar
- In Tkinter, which widget is used to create a progress bar?
- A) Progressbar
- B) Slider
- C) Gauge
- D) Meter
Answer: A) Progressbar
- In Java Swing, which component is used to create a slider to adjust a value within a range?
- A) JProgressBar
- B) JScrollbar
- C) JSlider
- D) JSpinner
Answer: C) JSlider
- In Tkinter, which widget is used for creating a radio button group where only one option can be selected at a time?
- A) Button
- B) Checkbutton
- C) Radiobutton
- D) Entry
Answer: C) Radiobutton
- In Java Swing, which method is used to remove a component from a container?
- A) removeComponent()
- B) delete()
- C) remove()
- D) clear()
Answer: C) remove()
- In Tkinter, which widget is used to create a canvas for drawing and displaying graphics?
- A) Frame
- B) Canvas
- C) Label
- D) Button
Answer: B) Canvas
- Which Java Swing component can be used to display a progress bar indicating the completion of a task?
- A) JProgressBar
- B) JSlider
- C) JScrollBar
- D) JTaskBar
Answer: A) JProgressBar
- In Tkinter, which method is used to create a menu bar for the window?
- A) create_menu()
- B) menu()
- C) add_menu()
- D) menubar()
Answer: D) menubar()
- Which layout manager in Java Swing arranges components into a grid of rows and columns?
- A) GridLayout
- B) FlowLayout
- C) BorderLayout
- D) GridBagLayout
Answer: A) GridLayout
- In Tkinter, which widget is used to display a scrollable text field for editing multiline text?
- A) Text
- B) Entry
- C) Label
- D) Listbox
Answer: A) Text
- Which method in Java Swing is used to add a mouse listener to a component?
- A) addMouseListener()
- B) attachMouseListener()
- C) addListener()
- D) mouseListener()
Answer: A) addMouseListener()
- In Java Swing, which method is used to make a JFrame appear on the screen?
- A) show()
- B) setVisible(true)
- C) display()
- D) makeVisible()
Answer: B) setVisible(true)
- In Tkinter, which widget is used to create a menu with options that can be selected?
- A) Listbox
- B) Menu
- C) Button
- D) OptionMenu
Answer: B) Menu
- Which of the following is the correct method to set the text for a JLabel in Java Swing?
- A) setText()
- B) changeText()
- C) setLabel()
- D) modifyText()
Answer: A) setText()
- In Tkinter, which method is used to pack widgets into a parent container in a top-down order?
- A) pack()
- B) grid()
- C) place()
- D) insert()
Answer: A) pack()
- In Java Swing, which component is used to create a toggle button that can switch between two states?
- A) JCheckBox
- B) JRadioButton
- C) JToggleButton
- D) JButton
Answer: C) JToggleButton
- In Java Swing, which method is used to change the font of a component?
- A) setFont()
- B) changeFont()
- C) modifyFont()
- D) setTextFont()
Answer: A) setFont()
- In Tkinter, which widget is used to allow users to select a date?
- A) Datepicker
- B) Calendar
- C) CalendarWidget
- D) None of the above (Tkinter does not have a built-in date picker)
Answer: D) None of the above (Tkinter does not have a built-in date picker)
- Which method in Java Swing is used to add a listener to an action event of a button?
- A) addActionListener()
- B) addEventListener()
- C) setActionListener()
- D) onClick()
Answer: A) addActionListener()
- In Java Swing, which component is used to display a list of items in a vertical or horizontal list format?
- A) JList
- B) JComboBox
- C) JTextArea
- D) JTextField
Answer: A) JList
- In Tkinter, which method is used to display a dialog box that asks the user for confirmation?
- A) ask_question()
- B) askokcancel()
- C) confirm()
- D) messagebox.askquestion()
Answer: B) askokcancel()
- In Java Swing, which layout manager is designed to allow for flexible component positioning and sizing using grid constraints?
- A) GridBagLayout
- B) FlowLayout
- C) BorderLayout
- D) BoxLayout
Answer: A) GridBagLayout
- In Java Swing, what is the purpose of the JScrollPane component?
- A) To display images
- B) To add scroll functionality to a component
- C) To create a button panel
- D) To add a drop-down menu
Answer: B) To add scroll functionality to a component
- In Tkinter, which widget is used to create an option menu with a single selection from a list of choices?
- A) Listbox
- B) Radiobutton
- C) OptionMenu
- D) Checkbutton
Answer: C) OptionMenu
- In Java Swing, which method is used to add a component at a specified position in a container using BorderLayout?
- A) add()
- B) setPosition()
- C) addComponent()
- D) place()
Answer: A) add()
- In Tkinter, which method is used to set a widget’s position using the grid system?
- A) grid()
- B) pack()
- C) place()
- D) align()
Answer: A) grid()
- In Java Swing, what does the JMenuItem class represent?
- A) A button in a menu
- B) A menu bar
- C) A text field in a menu
- D) A separator in a menu
Answer: A) A button in a menu
- In Tkinter, which method is used to change the title of the main window?
- A) set_title()
- B) change_title()
- C) title()
- D) setWindowTitle()
Answer: C) title()
- Which class in Java Swing is used to handle mouse events on components?
- A) MouseListener
- B) MouseAdapter
- C) MouseEvent
- D) Both A and B
Answer: D) Both A and B
- In Tkinter, which widget is used to create an entry box where the user can type text?
- A) Label
- B) Text
- C) Entry
- D) Listbox
Answer: C) Entry