Home Tuitions

chapter-Java GUI Programming Using Swing-III

Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Java GUI Programming Using Swing-III

This page consists of Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Java GUI Programming Using Swing-III all the questions are uploaded for practice with detailed explanations of every question. To check the solution, click on the answer. 

Find below Important MCQ-Based Questions on Informatics Practices (IP) class 11 chapter-Java GUI Programming Using Swing-III

Important Questions for Informatics Practices (IP) class 11 chapter-Java GUI Programming Using Swing-III set-1

Informatics Practices - MCQ on Java GUI Programming Using Swing-III

Class XI

Q.1 An Object that can be set so that multiple items can be selected at the same time is

a) Combo Box.

b) List.

c) Radio Button.

d) Tree.

Answer:

(b) List.

Explanation- List contains attributes from which single or multiple selections can be made.

Q.2 The list selection mode where only one item can be selected at a time is

a) Single Selection.

b) Single Interval Selection.

c) Multiple Interval Selection.

d) List Selection Model.

Answer:

(a)Single Selection.

Explanation- User can select single item from the list at a time.

Q.3 The contents of an object that can be specified using an array of objects

a) JColumn.

b) JRow.

c) JList.

d) JTable

Answer:

(c)JList.

Explanation: A component that allows the user to select one or more objects from a list. A separate model, ListModel represents the contents of the list.

Q.4 A JList object generates a

a) Adjustment Event.

b) List Selection Listener.

c) Action Event.

d) Text Event.

Answer:

(b)List Selection Listener.

Explanation: Ifwe want to know when elements of a JList have been selected, we need to attach a List Selection Listener to the JList or the List Selection Model.

Q.5 The list selection mode is defined by a

a) ListSelectionModel.

b) SelectedIndices.

c) SelectedValue.

d) ListSelection.

Answer:

(a)ListSelectionModel.

Explanation: ListSelectionModel represents the current state of the selection for any of the components that display a list of values with stable indices. The selection is modelled as a set of intervals; each interval represents a contiguous range of selected list elements.

Q.6. Control that provides a menu from which the user can choose one of several options

a) Slider.

b) Check Box.

c) Combo Box.

d) Password Field.

Answer:

(c)Combo Box.

Explanation- A Combo Box allows the user to select one item from a group.

Q.7. A combo box generates an Action Event when the user

a) fixes a content.

b) adds an item.

c) removes an item.

d) makes a selection from it.

Answer:

(d) makes a selection from it.

Explanation- When the user selects an item from a combo box, an Action Event is generated.

Q.8. Object implementing an interface with an event handler method is

a) Mouse Event.

b) Component Event.

c) Event Listener.

d) Action Event.

Answer:

(c) Event listener.

Explanation- An Event Listener is an object to which a component has delegated the task of handling a particular kind of event. When a component experiences input, an event of an appropriate type is constructed; the event is then passed as an argument to a method call on the listener. Event listeners implement appropriate listener interfaces which contain methods appropriate for handling the particular kind of event at hand.

Q.9. Object that is created when event occurs are

a) Event listener.

b) Key Event.

c) Focus Event.

d) Event Object.

Answer:

(d) Event Object.

Explanation- The Event Object keeps tracks of various events that occur on the application.

Q.10. A list of items is made available through a drop box, the user selects exactly one item

a) JList.

b) JComboBox.

c) TitleBar.

d) MenuBar.

Answer:

(b) JComboBox.

Explanation- A JComboBox implements a pull-down menu in which the user can select only one option. An element of a JComboBox can also contain icons.

Q.11. A logical group of buttons, which ensures that only one is selected at a time is

a) Radio Button.

b) Check Box.

c) Combo Box.

d) List.

Answer:

(a)Radio Button.

Explanation- Radio Buttons are arranged in groups of two or more and displayed on screen. When the user selects a radio button, any previously selected radio button in the same group becomes deselected.

Q.12. A GUI component that is either selected or not is

a) JPanel.

b) JButton.

c) JCheckBox.

d) JList.

Answer:

(c) JCheckBox.

Explanation- JCheckBox shows a small box that is either marked or unmarked. When you click on it, it changes from checked to unchecked or vice versa automatically.

Q.13. Method that changes the selection of indices specified by a given array is

a) setSelectedIndex().

b) setSelectionMode().

c) setSelectedValue().

d) setSelectIndices().

Answer:

(d)setSelectIndices().

Explanation- This method changes the selection to be set of indices specified by the given array; Indices greater than or equal to the model size is ignored. The parameter is an array that contains indices of the cells to select.

Q.14. Component for presenting many choices to a user is

a) JCombo Box.

b) JList.

c) JButton.

d) Text Field.

Answer:

(b) JList.

Explanation- A JList component class allows single or multiple selections of list items.

Q.15. Method that removes all the objects from the JComboBox is

a) removeItemAt().

b) removeItem().

c) removeAllItems().

d) setEdititem().

Answer:

(c) removeAllItems().

Explanation- This method removes all items from the combo box.

Q.16. The default form of combo box is

a) editable.

b) uneditable.

c) enabled.

d) disable.

Answer:

(b) uneditable.

Explanation- A JComboBox, which lets the user choose one of several choices, can have two very different forms. The default form is the uneditable combo box, which features a button and a drop-down list of values.

Q.17. Control that allows single or multiple selection of item is

a) Scroll Pane.

b) Scroll Bar.

c) Combo Box.

d) List.

Answer:

(d) List.

Explanation- A List allows single or multiple selections of list items. Items that are stored in a list have an associated property known as index.

Q.18. The object containing data to be exhibited by the list is

a) Index.

b) Count.

c) Model.

d) Mode.

Answer:

(c) Model.

Explanation- The Model of the list is an associated object that stores the data displayed by the list.

Q.19. Method that returns an array of all selected values is

a) getValue().

b) getSelectedValues().

c) getcurrentvalue().

d) getSelectedValue ().

Answer:

(b) getSelectedValues().

Explanation- This method returns an array of all the selected values in increasing order based on their indices in the list.

Q.20. When selection changes in the list, the list fires

a) List Selection event.

b) Index Selection event.

c) Focus Changed event.

d) Selected index event.

Answer:

(a) List Selection event.

Explanation- List fires List Selection event when the user selects or unselects an item from the list.

Q.21. Constructor method which creates a list model without any entries is

a) getNextMatch().

b) isEmpty().

c) DefaultListModel().

d) ListModelgetModel().

Answer:

(c) DefaultListModel().

Explanation- DefaultListModel is default implementation of ListModel to create Jlist.

Q.22. Method that sets the rows to be displayed is

a) selectedMode.

b) majorRowSpacing.

c) minorRowSpacing.

d) visibleRowCount.

Answer:

(d)visibleRowCount.

Explanation- This method sets the preferred number of rows to display without requiring scrolling.

Q.23. List selection events are processed through a

a) List Selection Listener.

b) JList Component.

c) SetEnabled Method.

d) setVisible() Method.

Answer:

(a) List Selection Listener.

Explanation- List fires List Selection events when the selection changes; these events are processed through a List Selection Listener.

Q.24. When an item is added to a list, each item gets a value known as

a) Token.

b) Index.

c) Position.

d) Interval.

Answer:

(b)Index.

Explanation- When an item is added to a list, then each item gets a unique associated value known as its Index.

Q.25. Event that is fired when the user selects an item from a menu is

a) Menu Event.

b) Command Event.

c) Action Event.

d) User Action Event.

Answer:

(c) Action Event.

Explanation- An Action Event occurs, whenever an action is performed by the user.

Q.26 Component that implements a drop down list is

a) Check Box.

b) Radio Button

c) Text Field.

d) Combo Box.

Answer:

(d)Combo Box.

Explanation- The JComboBox implements a drop-down list in which one item is displayed, along with a button displaying a down arrow.

Q.27. ActionListener is

a) a class.

b) an interface.

c) an instance variable.

d) a method.

Answer:

(b)an interface.

Explanation- ActionListener is an interface that contains the single method.

Q.28. The method used to get the item selected by the user is

a) setSelectionItem.

b) getSelectedIndex.

c) getSelectedItem.

d) addItem.

Answer:

(c)getSelectedItem.

Explanation- To get the item selected by the user, we use getSelectedItem method which returns an Object type.

Q.29. To repeat a task after a specified period, use

a) Swing Timers.

b) Swing Repeaters.

c) Swing Sliders.

d) Swing StopWatch.

Answer:

(a) Swing Timers.

Explanation- To repeat a task after a specified period such as updating a time display can be done using Swing Timers.

Q.30 A Combo Box is a cross between

a) Text area and list.

b) Check box and text field.

c) Text field and list.

d) List and radio button.

Answer:

(c) Text field and list.

Explanation- A combo box appears as a text field along with a drop-down list arrow from which the user can choose a value.

Q.31. To start the timer, syntax used is

a) timer=new timer().

b) < timer-object >.stop().

c) < timer>.start.

d) < timer-object >.start().

Answer:

(d) < timer-object >.start().

Explanation- Syntax used to start the timer is < timer-object>.start; for example: tmr.start(); .

Q.32. Random integers can be generated by importing

a) java.util.random class.

b) java.lib.random class.

c) java.awt.Container.

d) java.awt.Component

Answer:

(a) java.util.random class.

Explanation-This method returns the number of values between major ticks, i.e., the distance measured in values, between each major tick mark.

Q. 33. Index of the first item used in list is

a) 1.

b) 20.

c) 0.

d) -1.

Answer:

(c) 0.

Explanation- The first item of the list has index as 0, second item of the list has index as 1 and so on. When the user selects an item from the list, the corresponding index becomes selected index.

Q.34. Method that returns the value of selected item is

a) getvalue()

b) getSelectedValue().

c) getSelectedIndex().

d) valueChanged().

Answer:

(b)getSelectedValue().

Explanation- To obtain the value of selected item we use getSelectedValue().

Q. 35. Drop box can be added in the form by clicking on Combo Box control in

a) Event section.

b) Properties section.

c) Palette section.

d) Design window.

Answer:

(c) Palette section.

Explanation- To add a combo box, we have to click on Combo Box control in the Swing Controls section of the palette.

Q.36. Purpose of calling actionPerformed (ActionEvent) is to be

a) called just after the user performs an action.

b) called just before the user performs an action.

c) called after an action is done.

d) called just before the user decides to perform an action.

Answer:

(a) called just after the user performs an action.

Explanation- When the user selects an item from a combo box, an Action event is generated, to handle the event actionPerformed() Event handler method is called.

Q.37. Method that specifies whether the combo box’s text field is editable or not is

a) getEditable().

b) setDefaultIndex.

c) setEditable().

d) setSelectionItem().

Answer:

(c) setEditable().

Explanation- We can change text field of a combo box to be editable by setting its editable property to true. This method specifies whether the combo box’s text is editable or not.

Q. 38. A combo box is created through

a) JComboBox.

b) Check Box.

c) Set of Boxes.

d) List.

Answer:

(a) JComboBox.

Explanation- A combo box is created through JComboBox component class.

Q.39. Method that returns the index of selected item is

a) getSelectedItem().

b) return().

c) setSelectedIndex().

d) getSelectedIndex().

Answer:

(d) getSelectedIndex().

Explanation- getSelectedIndex() method returns the index of selected item.

Q. 40. Method to obtain the indices of selected value in a list myList is

a) myList.setSelected()

b) myList.getSelectedIndices().

c) myListsetValue().

d) myListgetValue().

Answer:

(b) myList.getSelectedIndices().

Explanation- This method is used to obtain the indices of selected values in a list namely myList.

Q.41. To determine whether any element of a list is selected in list, namely, ChkLst is

a) if ChkLst.isSelectionEmpty()==true.

b) if ChkLst.Selected()==true.

c) if (ChkLst.isSelectionEmpty()==true).

d) if ChkLst.isSelectionEmpty()==NULL.

Answer:

(c) if (ChkLst.isSelectionEmpty()==true).

Explanation- To determine any element of a list(ChkLst) is selected or not we use

if(ChkLst.isSelectionEmpty()==true) {

:

} else {

}

Q.42. Control is transferred to the actionPerformed method when

a) Checkbox is clicked.

b) Radiobutton is clicked.

c) Actionbutton is clicked.

d) Actionlistener button is clicked.

Answer:

(d) Actionlistener button is clicked.

Explanation- When an ActionListener button is clicked, control is transferred to

the actionPerformed method.

Q.43. Object created by external action is an

a) External Event.

b) Editable.

c) Accessible object.

d) Event.

Answer:

(d) Event.

Explanation- An event is generated when an action is done.

Q.44. We can control the adding and removing of items from a Jlist by

a) always adding and removing from the bottom of the list.

b) keeping track using integers.

c) using a ListModel.

d) selecting multiple items.

Answer:

(c) using a ListModel.

Explanation- Jlist allows the user to select one or more objects from a list. A separate model, ListModel represents the contents of the list.

Q. 45. Event Listener that is used by Jlist is

a) ListListener.

b) ListSelectionListener.

c) ListSubmissionListener

d) ListActionListener.

Answer:

(b) ListSelectionListener.

Explanation- If we want to know when elements of a JList have been selected, we need to attach a ListSelectionListener to the JList or the ListSelectionModel.

Q. 46. Items are added to a ListModel using

a) addElement(Object);

b) addItem(Object);

c) addObject(Object);

d) addModel(Object);

Answer:

(a) addElement(Object);

Explanation- Adds the specified component to the end of the list.

Q.47. To remove all items from a ListModel use

a) delete().

b) getRid()

c) removeAllElements().

d) removeItem().

Answer:

(c) removeAllElements().

Explanation- To remove all elements in a list we use void removeAllElements() method.

Q.48. A way of displaying a selectable list on the screen is

a) JFrame.

b) JPanel.

c) JLabel

d) Jlist.

Answer:

(d) Jlist.

Explanation- The JList is a way of displaying a selectable list on the screen.

Q. 49. A very handy drop-down menu is

a) JFrame.

b) JRadio Button.

c) JComboBox.

d) JCheck Box.

Ans. c) JComboBox.

Explanation- The JComboBox is a very handy drop-down menu component that selects one option from a list of things.

Q. 50. The JList is sized by using

a) selectedIndices().

b) setVisibleRowCount().

c) visibleCount().

d) selectedMode.

Answer:

(b) setVisibleRowCount().

Explanation- The JList is sized by using setVisibleRowCount() to tell the LayoutManager the number of rows that should be visible.

Q. 51. Component that represents its items in a column is

a) Jtext field.

b) JLabel.

c) JPanel.

d) JList.

Answer:

(d) Jlist.

Explanation- A JList component represents its items in a column.

Q. 52. To show a tooltip on a individual items of Jlist use

a) settooltip(true).

b) getToolTipText.

c) setnewItem(true).

d) setToolTip.

Answer:

(b) getToolTipText.

Explanation- To show a tooltip on a individual items of Jlist, override the JList method getToolTipText, determine the particular JList item the mouse is pointed on and show the appropriate text.

Q. 53. Component that do not offer text field for editing selected items is

a) Text Area.

b) Label.

c) List.

d) Combo Box.

Answer:

(c) List.

Explanation- A list does not have a text field which the user can use to edit the selected item.

Q. 54. A combination of a text field and a drop-down list is

a) Combo Box.

b) Check Box.

c) Text Box.

d) Frame.

Answer:

(a)Combo Box.

Explanation- A combo box is a combination of a text field and a drop-down list where the user can choose a value. It's very similar to a JList.

Q.55. Property that returns the index of selected item is

a) selecetdItem.

b) insertElement.

c) selectedIndex.

d) default index.

Answer:

(c) selectedIndex.

Explanation- This property returns the index of selected item or -1 if there is none.

Q.56. An object that is a simple container class that groups other objects is

a) JPanel.

b) JMenu.

c) JButton.

d) JTextArea.

Answer:

(a) JPanel.

Explanation- A Panel is a type of container that is designed to hold components like Combo box, Radio buttons, Lists etc.

Q.57. When we create the timer, we specify a/an

a) Action Event.

b) Event.

c) Action Listener.

d) Item.

Answer:

(c)Action Listener.

Explanation- When we create the timer, we specify an action listener to be notified when the timer "goes off".

Q. 58. Swing Timers are used to perform

a) Single action.

b) Multiple action.

c) Repeated action.

d) Periodic action.

Answer:

(d) Periodic action.

Explanation- When we need to repeat a task after a specified period that can be performed through timers.

Q.59. Component used for selecting a small set of qualified options is

a) Radio Button.

b) Combo Box.

c) List.

d) File Chooser.

Answer:

(b) Combo Box.

Explanation- A JComboBox is another way to display a small list of items.

Q.60. Whenever an option is selected from a JComboBox, a/an

a) ActionEvent is fired.

b) ActionListener is fired.

c) DefaultComboBoxModel is fired.

d) ComboBoxDemo

Answer:

(a) ActionEvent is fired.

Explanation- An ActionEvent is fired whenever an option is selected from a JComboBox or when the DefaultComboBoxModel is updated.

Q. 61. Component allowing users to select from a large list of options is

a) Panel.

b) Label.

c) Form.

d) List.

Answer:

(d)List.

Explanation- The JList component allows users to select from a large list of options.

Q.62. Whenever an element is selected from a list, it fires

a) List Model.

b) List Selection Listener.

c) JList Object.

d) Action Event.

Answer:

(b) List Selection Listener.

Explanation- Whenever an element is selected from a list or whenever a DefaultListModel is updated, a ListSelectionListener event is fired. An element selection invokes the ListSelectionListener event handler.

Q.63. The cell height of a JList can be defined by setting the

a) setFixedCellWidth(int width).

b) setLabel meyhod.

c) setFixedCellHeight(int height).

d) getValue method.

Answer:

(c) setFixedCellHeight(int height).

Explanation- The method sets the height of every cell in the list.

Q.64. To detect a selection change on a JComboBox

a) add an Item Listener.

b) add PropertyChange Events.

c) use Action Listener.

d) use Adjustment Listener.

Answer:

(c) use Action Listener.

Explanation- An Action Listener is an event handler interface for a class that can respond to user events.

Q.65. getSelectedItem method returns

a) Class type.

b) Object type.

c) Item type.

d) Instance.

Answer:

(b) Object type.

Explanation- To get item selected by the user, we use getSelectedItem which returns an Object type.

Q.66. To create a editable JComboBox, use method

a) setEditable.

b) getEditable.

c) editable.

d) setEnable.

Answer:

(a) setEditable.

Explanation- Text field of a combo box is uneditable, but it can be change to editable by setting its editable property to true.

Q. 67. Combo Box along with Item Events, generates one more event, i.e., a/an

a) ActionPerformed Method.

b) PopupMenu Event.

c) Action Event.

d) Item Listener.

Answer:

(c) Action Event.

Explanation- When the user selects an item from a combo box, an Action Event gets generated.

Q. 68. If only a single item needs to be selected, it is easy to use

a) Timer.

b) List.

c) List Model.

d) Combo Box.

Answer:

(d) Combo Box.

Explanation- Combo Box allows the user to choose a single item selection.

Q. 69. Combo Box is created through

a) ACombo Box component.

b) BCombo Box component.

c) JCombo Box component.

d) SCombo Box component.

Answer:

(c) JCombo Box component.

Explanation- In Java Swing, combo box can be created through JCombo Box component class.

Q.70. To start the timer, just call its

a) Event.

b) Start() method.

c) Stop method.

d) Timer object.

Answer:

(b) Start() method.

Explanation- When we need to start the timer, we call start() method, e.g., tmr.start(); .

Q.71. Combo box is preferred over a list as it takes

a) more space on screen.

b) equal space on screen.

c) no space on screen.

d) less space on screen.

Answer:

(d)less space on screen.

Explanation- A combo box is preferred over a list as it takes less space on the screen and drops down when user clicks on its arrow.

Q.72. Multiple item selection is possible only when the list selection mode is set to

a) SINGLE.

b) DOUBLE.

c) MULTIPLE_INTERVAL.

d) DOUBLE_MODE.

Answer:

(c) MULTIPLE_INTERVAL.

Explanation- Using MULTIPLE_INTERVAL selection mode, user can select multiple ranges of items within a list.

Q.73. User can select single range of items using

a) SINGLE selection mode.

b) SINGLE_INTERVAL mode.

c) MULTIPLE_INTERVAL mode.

d) SINGLE_ITEM mode.

Answer:

(b) SINGLE_INTERVAL mode.

Explanation- SINGLE_INTERVAL list selection mode helps user to select single range of items by holding Shift key and clicking on the items.

Q.74. ListSelection events are handled by

a) valueChanged().

b) valueSelect().

c) checkValue().

d) currentValue().

Answer:

(a) valueChanged().

Explanation- JList events are process through ListSelectionListener which handles event by valueChanged() method.

Q.75. Method that indicates whether text field in combo box is editable is

a) selected(true).

b) isEnabled().

c) isSelected().

d) isEditable().

Answer:

(d) isEditable().

Explanation- isEditable() method indicates whether the combo box’s text field is editable or not.

Q.76. A list displays list of values in a

a) box shaped control.

b) cylindrical shaped control .

c) button shaped control.

d) polygon shaped control.

Answer:

(a) box shaped control.

Explanation- A List displays list of values in a box shaped control.

Q. 77. Mechanism to fire events periodically through

a) Swinger.

b) Repeater.

c) Timer.

d) Randomizer.

Answer:

(c) Timer.

Explanation- Periodic actions are performed and implemented through timers.

Q. 78. Action event is sent to

a) Action Performed method.

b) Mouse Event.

c) Window Event.

d) Action Listener.

Answer:

(d) Action Listener.

Explanation- We implement an action listener to define what should be done when a user performs certain operation.

Q. 79. Property on a Combo Box to set a column name is

a) CompareValidator control.

b) DataTextField.

c) VisibleColumn.

d) Clearselection.

Answer:

(b) DataTextField.

Explanation- DataTextField property on a Combo Box helps to set a column name, prior to setting the DataSource, to display data in the combo box.

Q.80. The difference between a LIST BOX and a COMBO BOX is

a) a list box is a data entry area while a combo box can be used only for control purposes

b) in a combo box, the user is restricted to selecting a value from a list but in a list box the user can type in a value which is not in the list

c) in the list box, the user is restricted to selecting a value from a list but in a combo box the user can type in a value which is not in the list.

d) list is a part of Swing while combo box is not included in Swing.

Answer:

(c) In the list box, the user is restricted to selecting a value from a list but in a combo box the user can type in a value which is not in the list.

Explanation- In the list box, the user is restricted to selecting a value from a list but in a combo box the user can type in a value which is not in the list. A list doesn’t have a text field which user can edit.

Q.81. Swing components using ListSelectionModel is

a) JFrame.

b) JLabel.

c) JPanel.

d) JList.

Answer:

(d) JList.

Explanation- The selection state of a JList is managed by an instance of ListSelectionModel.

Q.82. A component that looks like a button and that, when pressed, brings up a menu of items for the user to choose from

a) Uneditable combo box.

b) Editable combo box.

c) Radio button.

d) Check box.

Answer:

(a) Uneditable combo box.

Explanation- A JComboBox, which lets the user choose one of several choices, can have two very different forms. The default form is the uneditable combo box, which features a button and a drop-down list of values.

Q.83. A javax.swing.Timer object calls an action listener at regular intervals or

a) twice.

b) only once.

c) repeatedly.

d) frequently.

Answer:

(b) only once.

Explanation- A javax.swing.Timer object calls an action listener at regular intervals or only once. Swing timers can be used in two ways: To perform a task once, after a delay or to perform a task repeatedly.

Q.84. Component that provides a scrollable set of items from which one or more may be selected is

a) JTabbed Pane.

b) JCombo Box.

c) JList.

d) JCheck Box.

Answer:

(c) JList.

Explanation- JList provides a scrollable set of items from which one or more may be selected. JList can be populated from an Array or Vector.

Q.85. A swing component that displays lists of objects within a box

a) Label.

b) List.

c) Panel.

d) Check Box.

Answer:

(b) List.

Explanation- A list is a swing component that displays lists of objects within a box.