You are on page 1of 65

UNIT 1

1. JPanel and Applet use ___________________ as their default layout

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: A) `FlowLayout`

2. Which are various AWT controls from following?

Options:
- A) Labels
- B) Push buttons
- C) Checkboxes
- D) Choice lists

Answer: A, B, C, D (All of the above)

3. Which of the following component class cannot be added on an applet?

Options:
- A) `Menu`
- B) `Button`
- C) `Label`
- D) `Checkbox`

Answer: A) `Menu`

1|Page
UNIT 1

4. A checkbox is a control that consists of a ____________

Options:
- A) Small box and a Label
- B) Radio button
- C) Dropdown list
- D) Text box

Answer: A) Small box and a Label

5. A Frame's _______________ designates the area of the frame excluding the title, menu bar,
and the border.

Options:
- A) `ContentPane`
- B) `BorderPane`
- C) `MainPane`
- D) `Panel`

Answer: A) `ContentPane`

6. A GUI stands for _____________.

Options:
- A) Graphical User Instruction
- B) Graphical User Interface
- C) General Use Interaction
- D) Graphic Understanding Interface

Answer: B) Graphical User Interface

2|Page
UNIT 1

7. A JCheckBoxMenuItem is a subclass of ________.

Options:
- A) `Checkbox`
- B) `MenuItem`
- C) `Button`
- D) All of these

Answer: D) All of these

8. A label is a simple control which is used to display ___________________ on the window

Options:
- A) Editable text
- B) Non-editable text
- C) Images only
- D) Both text and images

Answer: B) Non-editable text

9. A ScrollPane is _______________

Options:
- A) Control
- B) Container
- C) Panel
- D) Layout

Answer: B) Container

3|Page
UNIT 1

10. A superclass of `TextField` and `TextArea` classes that is used to create single-line, multiline
text fields respectively is_____

Options:
- A) `TextComponent`
- B) `TextInput`
- C) `TextFrame`
- D) `TextPane`

Answer: A) `TextComponent`

11. A _______ is a component that appears as a group of folders in a file cabinet.

Options:
- A) `JTabbedPane`
- B) `JFolderComponent`
- C) `FileCabinet`
- D) `FolderPanel`

Answer: A) `JTabbedPane`

12. A __________ automatically arranges the components added to a container.

Options:
- A) Display Manager
- B) Component Organizer
- C) Layout Manager
- D) Container Manager

Answer: C) Layout Manager

4|Page
UNIT 1

13. A ____________ is a passive AWT control which does not generate any event.

Options:
- A) `Button`
- B) `Label`
- C) `Checkbox`
- D) `TextField`

Answer: B) `Label`

14. A ____________________ component is a display area for a short string of text, image, or
both.

Options:
- A) `TextDisplay`
- B) `DisplayPane`
- C) `TextLabel`
- D) `JLabel`

Answer: D) `JLabel`

15. All Components on Container can be removed by calling the following method

Options:
- A) `remove()`
- B) `deleteAll()`
- C) `clear()`
- D) `removeAll()`

Answer: D) `removeAll()`

5|Page
UNIT 1

16. All Swing component classes are placed in ______________

Options:
- A) `java.awt`
- B) `javax.swing`
- C) `java.swing`
- D) `awt.swing`

Answer: B) `javax.swing`

17. An Applet is ______________ of Panel

Options:
- A) `Parent`
- B) `Child`
- C) `Superclass`
- D) `Subclass`

Answer: D) `Subclass`

18. Applet Container is used to prepare ________________ output window

Options:
- A) Text-based
- B) Graphics-based
- C) Both text-based and graphics-based
- D) Neither text-based nor graphics-based

Answer: C) Both text-based and graphics-based

6|Page
UNIT 1

19. AppletViewer tool is available in which folder of JDK

Options:
- A) `lib`
- B) `bin`
- C) `jdk`
- D) `jre`

Answer: B) `bin`

20 .Which layout manager ensures that only one component is visible at a time?

Options:

A) FlowLayout
B) BorderLayout
C) GridLayout
D) CardLayout
Answer: D) CardLayout

21. At the top of the AWT hierarchy is the__________________ class.

Options:

A) Panel
B) Container
C) Frame
D) Component
Answer: D) Component

7|Page
UNIT 1

22. AWT classes are contained in the __________ package.

Options:

A) java.awt
B) javax.swing
C) java.awt.event
D) java.util
Answer: A) java.awt

23.AWT is used for creating a GUI in Java. AWT stands for

Options:

A) Abstract Window Toolkit


B) Advanced Window Technology
C) Application Window Tools
D) Adaptive Widget Technology
Answer: A) Abstract Window Toolkit

24.AWTEvent Class is defined in the following package.

Options:

A) java.awt.event
B) java.awt
C) java.util
D) javax.swing
Answer: A) java.awt.event

8|Page
UNIT 1

25.A ________ is a Component that represents a hierarchical view of data.

Options:

A) JList
B) JTree
C) JTable
D) JComboBox
Answer: B) JTree

26.A _______________ is a component that presents a rectangular area in which a component


may be viewed.

Options:

A) ScrollPane
B) Panel
C) Frame
D) Canvas
Answer: A) ScrollPane

27. BorderLayout is divided into __________ regions.

Options:

A) three
B) four
C) five
D) six
Answer: C) five

28.BorderLayout class has __________ regions to add components to it.

9|Page
UNIT 1

Options:

A) three
B) four
C) five
D) six
Answer: C) five

29.By default, FlowLayout uses __________ justification.

Options:

A) Left
B) Right
C) Center
D) Top
Answer: C) Center

30 .By default, the page-up and page-down increment of a scrollbar is __________.

Options:

A) 5
B) 10
C) 15
D) 20
Answer: B) 10

10 | P a g e
UNIT 1

31. By default, the Frame has a ________________________________

Options:
- A) `Titlebar, borders, resizing corners`
- B) `Titlebar, menu bar, status bar`
- C) `Borders, content area, menu bar`
- D) `Content area, status bar, resizing corners`

Answer: A) `Titlebar, borders, resizing corners`

32. By default, which layout manager is set on an applet?

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: A) `FlowLayout`

33. By which method can you set or change the text in a Label?

Options:
- A) `setText()`
- B) `changeText()`
- C) `setLabel()`
- D) `updateText()`

Answer: A) `setText()`

11 | P a g e
UNIT 1

34. Canvas is a ________________

Options:
- A) `Component`
- B) `Window`
- C) `Container`
- D) `Panel`

Answer: A) `Component`

35. Checkable menu items are created using an object of which class?

Options:
- A) `CheckboxMenuItem`
- B) `JMenuItem`
- C) `Menu`
- D) `PopupMenu`

Answer: A) `CheckboxMenuItem`

36. Choose the incorrect statement

Options:
- A) `BorderLayout b = new BorderLayout(3,4);`
- B) `FlowLayout is a default layout for JPanel.`
- C) `JButton is a subclass of AbstractButton.`
- D) `JFrame is a subclass of Window.`

Answer: A) `BorderLayout b = new BorderLayout(3,4);`

12 | P a g e
UNIT 1

37. Combobox is a combination of ________________________

Options:
- A) `TextField and Dropdown List`
- B) `Button and List`
- C) `Label and List`
- D) `TextArea and Dropdown List`

Answer: A) `TextField and Dropdown List`

38. Components are added to which pane of the Swing JApplet.

Options:
- A) `ContentPane`
- B) `MenuPane`
- C) `FramePane`
- D) `PanelPane`

Answer: A) `ContentPane`

39. Constructors of JSeparator are

Options:
- A) `JSeparator()`
- B) `JSeparator(int orientation)`
- C) `Both i and ii`
- D) `None of the above`

Answer: C) `Both i and ii`

13 | P a g e
UNIT 1

40. Container is a subclass of?

Options:
- A) `Component`
- B) `JComponent`
- C) `Window`
- D) `Panel`

Answer: A) `Component`

41. Controls not supported by AWT are

Options:
- A) `TabbedPane, Table`
- B) `JTabbedPane, JTable`
- C) `ScrollPane, JTable`
- D) `JScrollPane, JTable`

Answer: A) `TabbedPane, Table`

42. The current text of a label can be obtained using ___________________.

Options:
- A) `getText()`
- B) `getCurrentText()`
- C) `retrieveText()`
- D) `fetchText()`

Answer: A) `getText()`

14 | P a g e
UNIT 1

43. Default layout manager for a Frame is ___________________.

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: B) `BorderLayout`

44. Default layout manager for a Panel is

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: A) `FlowLayout`

45. Default layout manager for a Window is

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: B) `BorderLayout`

15 | P a g e
UNIT 1

46. Default Layout of a Frame is

Options:
- A) `FlowLayout`
- B) `BorderLayout`
- C) `GridLayout`
- D) `CardLayout`

Answer: B) `BorderLayout`

47. Default orientation of a progress bar is:

Options:
- A) `Horizontal`
- B) `Vertical`
- C) `Diagonal`
- D) `Circular`

Answer: A) `Horizontal`

48. Double-buffering built-in, tool tips, dockable toolbars, keyboard accelerators, custom
cursors, etc. are new features of _______?

Options:
- A) `AWT`
- B) `Swing`
- C) `JFrame`
- D) `JComponent`

Answer: B) `Swing`

16 | P a g e
UNIT 1

49. Each menu is associated with a ___________ list of menu items

Options:
- A) `Pop-up`
- B) `Drop-down`
- C) `Roll-out`
- D) `Pull-down`

Answer: B) `Drop-down`

50. Every layout manager is an instance of __________.

Options:
- A) `the LayoutManager interface`
- B) `the Container interface`
- C) `the Component interface`
- D) `the Swing interface`

Answer: A) `the LayoutManager interface`

51. Executable applet is nothing but _________ file of an applet.

Options:
- A) `.exe`
- B) `.jar`
- C) `.class`
- D) `.app`

Answer: C)

17 | P a g e
UNIT 1

52. FileDialog is which kind of dialog box?

Options:
- A) Modal type
- B) Modeless type
- C) Resizable type
- D) Non-modal type

Answer: A) Modal type

53. FlowLayout arranges components from

Options:
- A) Left to Right
- B) Right to Left
- C) Top to Bottom
- D) Bottom to Top

Answer: A) Left to Right

54. FlowLayout does not support this value of alignment…

Options:
- A) `FlowLayout.LEFT`
- B) `FlowLayout.RIGHT`
- C) `FlowLayout.BASELINE`
- D) `FlowLayout.CENTER`

Answer: C) `FlowLayout.BASELINE`

18 | P a g e
UNIT 1

55. Font class is available in ___________

Options:
- A) `java.awt` package
- B) `java.swing` package
- C) `java.util` package
- D) `java.io` package

Answer: A) `java.awt` package

56. For adding controls to a window, we use the following method

Options:
- A) `addElement()`
- B) `addControl()`
- C) `addObject()`
- D) `add()`

Answer: D) `add()`

57. For using Swing control, one must import______________________________ package

Options:
- A) `java.awt`
- B) `javax.swing`
- C) `java.util`
- D) `java.io`

Answer: B) `javax.swing`

19 | P a g e
UNIT 1

58. Frame is a standard window, which is ____________________ of Window class from AWT
hierarchy

Options:
- A) superclass
- B) subclass
- C) child class
- D) parent class

Answer: B) subclass

59. getContentPane() method of which class

Options:
- A) `JFrame`
- B) `JApplet`
- C) `JPanel`
- D) `JWindow`

Answer: B) `JApplet`

60. getSelectedCheckbox() method of which class

Options:
- A) `CheckboxGroup`
- B) `Checkbox`
- C) `CheckboxMenuItem`
- D) `CheckboxGroup`

Answer: A) `CheckboxGroup`

20 | P a g e
UNIT 1

61. How can the Checkbox class be used to create a radio button in AWT?

Options:
- A) By associating Checkbox objects with a CheckboxGroup
- B) By setting the Checkbox's style to "Radio"
- C) By using Checkbox directly, it cannot be used to create a radio button
- D) By using a special constructor for Checkbox for radio button creation

Answer: A) By associating Checkbox objects with a CheckboxGroup

62. How do you change the current layout managers for a container?

Options:
- A) Use the setLayout() method
- B) Use the addLayout() method
- C) Use the changeLayout() method
- D) Use the modifyLayout() method

Answer: A) Use the setLayout() method

63. How many checkboxes can we check at a time?

Options:
- A) Single
- B) Double
- C) Multiple
- D) Unlimited

Answer: C) Multiple

21 | P a g e
UNIT 1

64. How To Apply Image To Button?

Options:
- A) Using setImage() method
- B) Using setIcon() method
- C) Using setImageIcon() method
- D) Using addButtonImage() method

Answer: B) Using setIcon() method

65. How would you set the color of a graphics context called g to cyan?

Options:
- A) `g.setColor(Color.cyan);`
- B) `g.setCyanColor();`
- C) `g.setColor(cyan);`
- D) `g.setRGBColor(0, 255, 255);`

Answer: A) `g.setColor(Color.cyan);`

66. Identify the correct constructor of Font class?

Options:
- A) `Font(String name, int size)`
- B) `Font(int style, int size)`
- C) `Font(String name, int style, int size)`
- D) `Font(int style, int size, String name)`

Answer: C) `Font(String name, int style, int size)`

22 | P a g e
UNIT 1

67. Identify the wrong constructor of Checkbox

Options:
- A) `Checkbox()`
- B) `Checkbox(String label)`
- C) `Checkbox(String label, boolean state)`
- D) `None of Above`

Answer: D) `None of Above`

68. In applet, which of the following tag is used for accepting user-defined parameter?

Options:
- A) `<param>`
- B) `<app-param>`
- C) `<user-param>`
- D) `<input>`

Answer: A) `<param>`

69. In AWT Checkbox class is used to create __________

Options:
- A) Radio buttons
- B) Checkboxes
- C) Both Checkbox and Radio buttons
- D) Menus

Answer: C) Both Checkbox and Radio buttons

23 | P a g e
UNIT 1

70. In AWT Radio buttons are created using_____________________

Options:
- A) Checkbox
- B) CheckboxGroup
- C) RadioButton
- D) ButtonGroup

Answer: B) CheckboxGroup

71. In FlowLayout manager, the default space between each component is

Options:
- A) `5 pixels`
- B) `10 pixels`
- C) `15 pixels`
- D) `20 pixels`

Answer: A) `5 pixels`

72. In Graphics class, Which method is used to set the graphics current color to the specified
color?

Options:
- A) `public abstract void setColor(Color c)`
- B) `public void setCurrentColor(Color c)`
- C) `public void setDrawingColor(Color c)`
- D) `public void assignColor(Color c)`

Answer: A) `public abstract void setColor(Color c)`

24 | P a g e
UNIT 1

73. In how many ways can we define the scrollbar?

Options:
- A) `Only one way`
- B) `Two ways`
- C) `Three ways`
- D) `All of the above`

Answer: D) `All of the above`

74. In Swing, Buttons are the subclasses of which class?

Options:
- A) `AbstractButton`
- B) `JButton`
- C) `Button`
- D) `JComponent`

Answer: A) `AbstractButton`

75. In Swing, the content pane can be obtained via method________

Options:
- A) `getContent()`
- B) `getContentPane()`
- C) `fetchContentPane()`
- D) `retrieveContent()`

Answer: B) `getContentPane()`

25 | P a g e
UNIT 1

76. In Swing, ____________ is a component that displays rows and columns of data.

Options:
- A) `JTable`
- B) `JPanel`
- C) `JGrid`
- D) `JTextArea`

Answer: A) `JTable`

77. In Swing, tables are implemented by the ______________ class

Options:
- A) `JPanel`
- B) `JTable`
- C) `JScrollPane`
- D) `JGrid`

Answer: B) `JTable`

78. Identify which is a valid constructor of MenuItem class?

Options:
- A) `MenuItem()`
- B) `MenuItem(String Itemname)`
- C) `MenuItem(int ItemID)`
- D) `MenuItem(String Itemname, boolean enabled)`

Answer: B) `MenuItem(String Itemname)`

26 | P a g e
UNIT 1

79. Items are added in JComboBox using method……?

Options:
- A) `addItem()`
- B) `addObject()`
- C) `addElement()`
- D) `addItemToList()`

Answer: A) `addItem()`

80. JApplet class is Derived from

Options:
- A) `Applet`
- B) `JFrame`
- C) `JWindow`
- D) `Container`

Answer: A) `Applet`

81. Java supports input/output of data through the classes included in the _______ package:

Options:
- A) `Java.io`
- B) `Java.util`
- C) `Java.awt`
- D) `Java.net`

Answer: A) `Java.io`

27 | P a g e
UNIT 1

82. JCheckBox is _______________________Component

Options:
- A) `heavyweight`
- B) `lightweight`
- C) `system`
- D) `standard`

Answer: B) `lightweight`

83. JRadioButton is a subclass of ________.

Options:
- A) `AbstractButton`
- B) `JButton`
- C) `RadioButton`
- D) `ButtonGroup`

Answer: A) `AbstractButton`

84. JTabbedPane class is present in which package?

Options:
- A) `java.awt`
- B) `java.swing`
- C) `javax.awt`
- D) `javax.swing`

Answer: D) `javax.swing`

28 | P a g e
UNIT 1

85. JTree class comes under which package

Options:
- A) `javax.swing.tree`
- B) `java.awt.tree`
- C) `java.swing`
- D) `javax.swing`

Answer: A) `javax.swing.tree`

86. List can be created for multiple selection by using the following constructor.

Options:
- A) `List(int num, boolean multiselect)`
- B) `List(boolean multiselect)`
- C) `List(int num)`
- D) `List()`

Answer: A) `List(int num, boolean multiselect)`

87. Model is the _________ of the MVC architecture.

Options:
- A) `topmost`
- B) `middle`
- C) `bottom most level`
- D) `side component`

Answer: C) `bottom most level`

29 | P a g e
UNIT 1

88. A mouse click will always generate ________________ event?

Options:
- A) `ClickEvent`
- B) `MouseActionEvent`
- C) `MouseEvent`
- D) `MouseClickEvent`

Answer: C) `MouseEvent`

89. MutableTreeNode extends __________________interface

Options:
- A) `Node`
- B) `Mutable`
- C) `TreeNode`
- D) `MutableNode`

Answer: C) `TreeNode`

90. MVC Architecture is

Options:
- A) `Model-View-Control`
- B) `Model-View-Component`
- C) `Model-View-Coding`
- D) `Model-Visual-Control`

Answer: A) `Model-View-Control`

30 | P a g e
UNIT 1

91. Name the class used to represent a GUI application window, which is optionally resizable
and can have a title bar, an icon, and menus

Options:
- A) `Window`
- B) `JFrame`
- C) `Dialog`
- D) `Frame`

Answer: B) `JFrame`

92. On which side applet always executed?

Options:
- A) `Server side`
- B) `Client side`
- C) `Local side`
- D) `Remote side`

Answer: B) `Client side`

93. Package of drawString() method is

Options:
- A) `java.awt`
- B) `java.swing`
- C) `java.util`
- D) `java.io`

Answer: A) `java.awt`

31 | P a g e
UNIT 1

94. Panel is defined as

Options:
- A) `A lightweight container`
- B) `A heavyweight container`
- C) `Both A and B`
- D) `None of the above`

Answer: A) `A lightweight container`

95. Panel is used for __________ components

Options:
- A) `Rendering`
- B) `Grouping`
- C) `Layout`
- D) `Displaying`

Answer: B) `Grouping`

96. Pluggable Look & Feel is the feature of

Options:
- A) `Swing`
- B) `AWT`
- C) `JRE`
- D) `JVM`

Answer: A) `Swing`

32 | P a g e
UNIT 1

97. Positions the components into five regions: east, west, north, south, center

Options:
- A) `GridLayout`
- B) `BorderLayout`
- C) `FlowLayout`
- D) `CardLayout`

Answer: B) `BorderLayout`

98. A program which executes an applet is known as

Options:
- A) `AppletLoader`
- B) `AppletRunner`
- C) `AppletExecutor`
- D) `Appletviewer`

Answer: D) `Appletviewer`

99. Public class MenuBar extends ____________________

Options:
- A) `Menu`
- B) `MenuBar`
- C) `MenuItem`
- D) `MenuComponent`

Answer: D) `MenuComponent`

33 | P a g e
UNIT 1

100. Scrollbar() creates a ______________ scroll bar by default.

Options:
- A) `Vertical`
- B) `Horizontal`
- C) `Both Vertical and Horizontal`
- D) `None of the above`

Answer: A) `Vertical`

101. Select the proper constructor of FileDialog

Options:
- A) `FileDialog(Frame parent)`
- B) `FileDialog(String title, int mode)`
- C) `FileDialog(Dialog parent, String title, int mode)`
- D) `FileDialog()`

Answer: C) `FileDialog(Dialog parent, String title, int mode)`

102. Select the proper syntax to add a component in an applet

Options:
- A) `addComponent(Component comp)`
- B) `addToApplet(Component comp)`
- C) `add(comp)`
- D) `add(Component comp)`

Answer: D) `add(Component comp)`

34 | P a g e
UNIT 1

103. setBorder() method is used to set a border for ________?

Options:
- A) `Container`
- B) `JFrame`
- C) `JComponent`
- D) `JLabel`

Answer: C) `JComponent`

104. setMenuBar() method belongs to which class

Options:
- A) `Menu`
- B) `MenuBar`
- C) `Frame`
- D) `Window`

Answer: C) `Frame`

105. State true or false


i) AWT is an extended version of Swing
ii) Paint() of Applet class cannot be overridden

Options:
- A) `True - False`
- B) `False - True`
- C) `True - True`
- D) `False - False`

Answer: B) `False - True`

35 | P a g e
UNIT 1

106. Swing components are

Options:
- A) `Heavyweight and platform-specific`
- B) `Lightweight and platform-independent`
- C) `Heavyweight and platform-independent`
- D) `Lightweight and platform-specific`

Answer: B) `Lightweight and platform-independent`

107. Swing is the set of ____________ that provides more powerful & flexible components
compared to AWT.

Options:
- A) `Interfaces`
- B) `Classes`
- C) `Modules`
- D) `Methods`

Answer: B) `Classes`

108. Text field is usually called as

Options:
- A) `Text Box`
- B) `Entry Field`
- C) `Edit Control`
- D) `Input Area`

Answer: C) `Edit Control`

36 | P a g e
UNIT 1

109. TextField class is used for__________

Options:
- A) `Multi-Line text-entry area`
- B) `Single-Line text-entry area`
- C) `Displaying images`
- D) `Creating tables`

Answer: B) `Single-Line text-entry area`

110. The Applet class is in which package

Options:
- A) `java.awt`
- B) `java.applet`
- C) `javax.swing`
- D) `java.util`

Answer: B) `java.applet`

111. The AWT container is an instance of the ___________ class which holds various
components and other containers

Options:
- A) `Component`
- B) `Window`
- C) `Container`
- D) `JContainer`

Answer: C) `Container`

37 | P a g e
UNIT 1

112. The CardLayout class manages the components in such a manner that

Options:
- A) `Only one component is visible at a time`
- B) `Multiple components are visible at a time`
- C) `Components are displayed randomly`
- D) `Components are arranged in a stack`

Answer: A) `Only one component is visible at a time`

113. The concept of the menu bar can be implemented using three Java classes—

Options:
- A) `MenuBar, Menu, MenuItem`
- B) `JMenuBar, JMenu, JMenuItem`
- C) `Menu, MenuBar, MenuItem`
- D) `JMenu, JMenuItem, JMenuBar`

Answer: B) `JMenuBar, JMenu, JMenuItem`

114. The coordinate of the upper-left corner of a frame is ________.

Options:
- A) `(1, 1)`
- B) `(0, 0)`
- C) `(10, 10)`
- D) `(x, y)`

Answer: B) `(0, 0)`

38 | P a g e
UNIT 1

115. The correct hierarchy for the panel is

Options:
- A) `Component-Container-Panel`
- B) `Container-Component-Panel`
- C) `Panel-Container-Component`
- D) `Panel-Component-Container`

Answer: A) `Component-Container-Panel`

116. The default layout manager for the content pane of a Swing-based applet is

Options:
- A) `GridLayout`
- B) `BorderLayout`
- C) `FlowLayout`
- D) `CardLayout`

Answer: B) `BorderLayout`

117. The following specifies the advantages of Swing: It is lightweight. It supports pluggable
look and feel. It follows MVC (Model View Controller) architecture.

Options:
- A) `True`
- B) `False`

Answer: A) `True`

39 | P a g e
UNIT 1

118. The method `drawRect()` is used to display an __________________________.

Options:
- A) `Outlined circle`
- B) `Outlined square`
- C) `Outlined rectangle`
- D) `Outlined triangle`

Answer: C) `Outlined rectangle`

119. The method `setLabel` can be used with what type of Object?

Options:
- A) `Button`
- B) `Label`
- C) `TextField`
- D) `TextArea`

Answer: B) `Label`

120. The method _______________ creates an IconImage for the file `c:\image\us.gif`.

Options:
- A) `new Image("c:\image\us.gif")`
- B) `new ImageIcon("c:\image\us.gif")`
- C) `createIconImage("c:\image\us.gif")`
- D) `setIconImage("c:\image\us.gif")`

Answer: B) `new ImageIcon("c:\image\us.gif")`

40 | P a g e
UNIT 1

121. The method `setBackground()` is part of the following class in the `java.awt` package:

Options:
- A) `Component`
- B) `Container`
- C) `Window`
- D) `JComponent`

Answer: A) `Component`

122. The string parameter to the `JButton` constructor tells what text will appear on the button.

Options:
- A) `True`
- B) `False`

Answer: A) `True`

123. The Swing component classes that are used to encapsulate a mutually exclusive set of
buttons are?

Options:
- A) `ButtonGroup`
- B) `RadioButtonGroup`
- C) `ToggleButtonGroup`
- D) `CheckGroup`

Answer: A) `ButtonGroup`

41 | P a g e
UNIT 1

124. The syntax for the `drawRect()` method is

Options:
- A) `drawRect(int x, int y, int width, int height)`
- B) `drawRect(int top, int left, int width, int height)`
- C) `drawRect(int width, int height)`
- D) `drawRect(int x, int y)`

Answer: A) `drawRect(int x, int y, int width, int height)`

125. The TextArea controls create a ________ respectively.

Options:
- A) `Multi-line text`
- B) `Single-line text`
- C) `Formatted text`
- D) `Complex text`

Answer: A) `Multi-line text`

126. The various Controls Supported by AWT are

Options:
- A) `TabbedPane, Table`
- B) `Menu, Scrollbar`
- C) `Checkbox, TextField`
- D) `All of these`

Answer: D) `All of these`

42 | P a g e
UNIT 1

127. The ___________ arranges components in rows and columns and makes all components the
same size.

Options:
- A) `FlowLayout manager`
- B) `GridLayout manager`
- C) `BorderLayout manager`
- D) `CardLayout manager`

Answer: B) `GridLayout manager`

128. The _____________ class is used to create radio buttons in AWT

Options:
- A) `CheckBoxGroup`
- B) `RadioButton`
- C) `Checkbox`
- D) `ButtonGroup`

Answer: D) `ButtonGroup`

137. The ___________________ Can be used to enter or display a string


- Options:
- A) `textfield`
- B) `TextArea`
- C) `Label`
- D) `Button`
- Answer: A) `textfield`

43 | P a g e
UNIT 1

138. These four methods commonly used in? 1)public void add(Component c) 2)public void
setSize(int width,int height) 3)public void setLayout(LayoutManager m) 4)public void
setVisible(boolean)
- Options:
- A) `Component class`
- B) `Container class`
- C) `Panel class`
- D) `Frame class`
- Answer: A) `Component class`

139. To create a window with a title bar which of the following class is used?
- Options:
- A) `Panel`
- B) `Dialog`
- C) `Window`
- D) `Frame`
- Answer: D) `Frame`

140. To create a file dialog box ______________ class is used


- Options:
- A) `FileChooser`
- B) `FileDialog`
- C) `FilePicker`
- D) `FileSelector`
- Answer: B) `FileDialog`

141. To display text on the applet ______ method is used.


- Options:
- A) `drawText()`
- B) `displayText()`
- C) `displayText()`
- D) `drawString()`
- Answer: D) `drawString()`

44 | P a g e
UNIT 1

142. To draw a line in an applet, we use the following method


- Options:
- A) `drawLine()`
- B) `draw()`
- C) `line()`
- D) `drawLineTo()`
- Answer: A) `drawLine()`

143. To fetch the caption of a button, which method is used?


- Options:
- A) `getCaption()`
- B) `getLabel()`
- C) `getText()`
- D) `fetchLabel()`
- Answer: B) `getLabel()`

144. To retrieve the current state of a checkbox, call ___________________


- Options:
- A) `isChecked()`
- B) `getState()`
- C) `getCurrentState()`
- D) `checkBoxState()`
- Answer: B) `getState()`

145. We can add menus to _________________________


- Options:
- A) `Panels`
- B) `Frames`
- C) `Dialogs`
- D) `Labels`
- Answer: B) `Frames`

45 | P a g e
UNIT 1

146. What are controls or components?


- Options:
- A) `UI elements allowing user interaction`
- B) `Backend functions`
- C) `Data structures`
- D) `Software algorithms`
- Answer: A) `UI elements allowing user interaction`

147. What are the TextComponent?


A) TextField
B) TextArea
C) TextPane
D) TextEditor

Answer: A) TextField, B) TextArea

148. What Are The Types of Dialogbox?


A) Modal and Modeless Dialogbox
B) Pop-up and Inline Dialogbox
C) Synchronous and Asynchronous Dialogbox
D) Prompt and Alert Dialogbox
Answer: A) Modal and Modeless Dialogbox

149. What variables are defined in Dimension?


A) size and scale
B) height and width
C) length and breadth
D) diameter and radius

Answer: B) height and width

46 | P a g e
UNIT 1

150. Which Checkbox method allows you to tell if a Checkbox is checked?


A) isSelected()
B) isChecked()
C) getState()
D) isCheckedState()

Answer: C) getState()

151. What does the following line of code do? `TextField text = new TextField(10);`
A) Creates a text object with 10 rows of text.
B) Creates a text object with a limit of 10 characters.
C) Creates a text object that can hold 10 columns of text.
D) Creates a text object with a default size of 10 pixels.
Answer: C) Creates a text object that can hold 10 columns of text.

152. What is API?


A) Application Protocol Interface
B) Advanced Programming Interface
C) Application Programming Interface
D) Advanced Protocol Interface
Answer: C) Application Programming Interface

153. What is the default alignment of components using FlowLayout?


A) FlowLayout.LEFT
B) FlowLayout.CENTER
C) FlowLayout.RIGHT
D) FlowLayout.DEFAULT
Answer: B) FlowLayout.CENTER

47 | P a g e
UNIT 1

154. What is the default layout manager for panels and applets?
A) BorderLayout
B) FlowLayout
C) GridLayout
D) CardLayout
Answer: B) FlowLayout

155. What is the default layout for a dialog?


A) BorderLayout
B) FlowLayout
C) GridLayout
D) CardLayout
Answer: A) BorderLayout

156. What is the difference between a TextArea and a TextField?


A) TextArea supports images, while TextField doesn't.
B) TextField supports multiline text input, while TextArea doesn't.
C) TextArea can handle multiple lines of text, while TextField cannot.
D) TextField allows customizable fonts, while TextArea doesn't.
Answer: C) TextArea can handle multiple lines of text, while TextField cannot.

157. What is the minimum and maximum of JProgressBar?


A) Minimum -100, Maximum -0
B) Minimum 0, Maximum 100
C) Minimum 1, Maximum 100
D) Minimum -1, Maximum 1
Answer: B) Minimum 0, Maximum 100

48 | P a g e
UNIT 1

158. What is the use of the following method in JDialog? `Container getContentPane()`
A) Retrieves the content pane of the dialog.
B) Sets the title of the dialog.
C) Closes the dialog window.
D) Sets the layout of the dialog.
Answer: A) Retrieves the content pane of the dialog.

159. What is the use of the third parameter in the given constructor `Scrollbar(int, int, int, int,
int)`?
A) Scrollbar length
B) Scrollbar position
C) Thumbsize
D) Scrollbar orientation
Answer: C) Thumbsize

160. What is the use of the second parameter in the given constructor `Label(String, int)`?
A) Specifies the font size of the label.
B) Specifies the text color of the label.
C) Specifies the alignment of text in the label in terms of pixels.
D) Specifies the width of the label.
Answer: C) Specifies the alignment of text in the label in terms of pixels.

161. What layout manager should you use so that every component occupies the same size in the
container?
A) BorderLayout
B) FlowLayout
C) GridLayout
D) CardLayout
Answer: C) GridLayout

49 | P a g e
UNIT 1

162. What letter precedes Swing component names that have a corresponding AWT component?
A) A
B) J
C) S
D) W

Answer: B) J

163. What method is used to prevent a user from changing the size of a Frame() object?
A) setResizable(false)
B) setMovable(false)
C) setSizable(false)
D) setSizeLocked(true)

Answer: A) setResizable(false)

164. What methods are used to get and set the text label displayed by a Button object?
A) getLabel() and setLabel()
B) getText() and setText()
C) getTitle() and setTitle()
D) getValue() and setValue()

Answer: A) getLabel() and setLabel()

165. When a DialogBox is closed which method gets called?


A) close()
B) exit()
C) dispose()
D) destroy()

Answer: C) dispose()

50 | P a g e
UNIT 1

166. When the layout manager is disabled, which method is used to determine the shape and
position of the Component?
A) setLocation()
B) setBounds()
C) setPosition()
D) resize()

Answer: B) setBounds()

167. When we invoke repaint() for a java.awt.Component object, the AWT invokes the method:
A) update()
B) refresh()
C) redraw()
D) paint()

Answer: A) update()

168. Which method is used to set the visibility of the frame?


A) `setVisible(true)`
B) `showFrame()`
C) `display(true)`
D) `viewFrame(true)`

Answer: A) `setVisible(true)`

169. Which package do we need to import while writing a Swing `JRadioButton` class?
A) `java.awt`
B) `javax.swing.event`
C) `javax.swing`
D) `java.util`

Answer: C) `javax.swing`

51 | P a g e
UNIT 1

170. Which abstract class is the superclass of all menu-related classes?


A) `MenuClass`
B) `MenuHierarchy`
C) `MenuComponent`
D) `MenuRoot`

Answer: C) `MenuComponent`

171. Which among the below is not an AWT class?


A) `RadioButton`
B) `Checkbox`
C) `Frame`
D) `Button`

Answer: A) `RadioButton`

172. Which are the Alignment Constants of Label?


A) `LEFT`
B) `RIGHT`
C) `CENTER`
D) `All The Above`

Answer: D) `All The Above`

173. Which are the subclasses of the container class?


A) `Windows`, `Panel`, `ScrollPane`
B) `Frame`, `Dialog`, `Applet`
C) `Button`, `Checkbox`, `List`
D) `Canvas`, `Label`, `TextField`

Answer: A) `Windows`, `Panel`, `ScrollPane`

52 | P a g e
UNIT 1

174. Which AWT component is not editable?


A) `Label`
B) `TextField`
C) `Checkbox`
D) `Button`

Answer: A) `Label`

175. Which AWT control is used for multi-line text entry?


A) `TextArea`
B) `TextField`
C) `List`
D) `ComboBox`

Answer: A) `TextArea`

176. Which class can be used to represent a checkbox with a textual label that can appear in a
menu?
A) `CheckboxMenuItem`
B) `JCheckBoxMenuItem`
C) `MenuCheckbox`
D) `MenuItemCheckbox`

Answer: A) `CheckboxMenuItem`

53 | P a g e
UNIT 1

177. Which class creates a node in JTree?


A) `TreeNode`
B) `TreeNodeElement`
C) `JTreeNode`
D) `DefaultMutableTreeNode`

Answer: D) `DefaultMutableTreeNode`

178. Which class defines the `setSize()` method?


A) `Frame`
B) `Component`
C) `Window`
D) `Panel`

Answer: A) `Frame`

179. Which class encapsulates a blank window upon which we can draw?
A) `Frame`
B) `Dialog`
C) `Canvas`
D) `Window`

Answer: C) `Canvas`

180. Which class is at the top of the AWT event hierarchy?


A) `java.awt.AWTEvent`
B) `java.awt.Event`
C) `java.awt.ComponentEvent`
D) `java.awt.EventQueue`

Answer: A) `java.awt.AWTEvent`

54 | P a g e
UNIT 1

181. Which class is used to create a pop-up list of items from which the user may choose?
A) `PopupList`
B) `Choice`
C) `List`
D) `ComboBox`

Answer: B) `Choice`

182. Which Class is used to get the dimension of an Applet?


A) `Dimension`
B) `AppletDimension`
C) `AppletSize`
D) `AppletDimensionSize`

Answer: A) `Dimension`

183. Which class is used to represent a single-line textbox with password character facility?
A) `PasswordField`
B) `TextInputField`
C) `TextPassword`
D) `TextField`

Answer: A) `PasswordField`

184. Which class provides many methods for graphics programming?


A) `java.awt.Graphics`
B) `java.awt.Canvas`
C) `java.awt.Paint`
D) `java.awt.Draw`

Answer: A) `java.awt.Graphics`

55 | P a g e
UNIT 1

185. Which component cannot be added to a container?


A) `JFrame`
B) `JPanel`
C) `JLabel`
D) `JWindow`

Answer: A) `JFrame`

186. Which component displays information in a hierarchical manner with a parent-child


relationship?
A) `JTable`
B) `JTree`
C) `JList`
D) `JComboBox`

Answer: B) `JTree`

187. Which component in Swing represents data in rows and columns?


A) `JLabel`
B) `JTextField`
C) `JTable`
D) `JTextArea`

Answer: C) `JTable`

188. Which component of AWT provides a compact, multi-choice, scrolling selection?


A) `ComboBox`
B) `Choice`
C) `List`
D) `ScrollPane`

Answer: B) `list

56 | P a g e
UNIT 1

190. Which Container uses a BorderLayout as its default layout?


A) Panel
B) Frame
C) Window
D) All of the above

Answer: D) All of the above

191. Which containers may have a MenuBar?


A) Frame
B) Dialog
C) Panel
D) Applet

Answer: A) Frame

192. Which control is not contained in the AWT Package?


A) ScrollPane
B) TextField
C) Button
D) Label

Answer: A) ScrollPane

193. Which constructor creates a TextArea with 10 rows and 20 columns?


A) `new TextArea(10, 20)`
B) `new TextArea(20, 10)`
C) `new TextArea(10)`
D) `new TextArea(20)`

Answer: A) `new TextArea(10, 20)`

57 | P a g e
UNIT 1

194. Which control in Swing is a combination of a text field and a dropdown list?
A) JComboBox
B) JList
C) JComboField
D) JTextArea

Answer: A) JComboBox

195. Which is the correct method for adding a button component into the North region of
BorderLayout? Assume `b1` as a button object.
A) `add(b1, BorderLayout.NORTH)`
B) `set(b1, BorderLayout.NORTH)`
C) `insert(b1, BorderLayout.NORTH)`
D) `place(b1, BorderLayout.NORTH)`

Answer: A) `add(b1, BorderLayout.NORTH)`

196. Which is the default layout Manager for JApplet?


A) BorderLayout
B) FlowLayout
C) GridLayout
D) CardLayout

Answer: A) BorderLayout

58 | P a g e
UNIT 1

197. Which is the immediate superclass for TextField?


A) Component
B) Container
C) TextComponent
D) Field

Answer: C) TextComponent

198. Which is the constructor of JTabbedPane?


A) `JTabbedPane()`
B) `JTabbedPane(int tabPlacement)`
C) Both option A and B
D) None of the above

Answer: C) Both option A and B

199. Which is the correct constructor for JProgressBar?


A) `JProgressBar()`
B) `JProgressBar(int min, int max)`
C) `JProgressBar(int orientation)`
D) All of the above

Answer: D) All of the above

200. Which is the correct constructor of GridLayout?


A) `GridLayout(int rows, int cols)`
B) `GridLayout(int numrows, int numcols)`
C) `GridLayout(int columns, int rows)`
D) `GridLayout(int cols, int rows)`

Answer: A) `GridLayout(int rows, int cols)`

59 | P a g e
UNIT 1

201. Which is the immediate superclass of Applet?


A) Component
B) Container
C) Panel
D) Window

Answer: A) Panel

202. Which method is used to count the number of items in the list?
A) `getCount()`
B) `getItemCount()`
C) `countItems()`
D) `getItemsCount()`

Answer: B) `getItemCount()`

203. Which is true about Swing?


A) It is an extension of AWT.
B) It provides lightweight components.
C) It offers a rich set of controls.
D) All of the above

Answer: D) All of the above

204. Which are the various methods of the TextField control from the following?
A) `getText()`, `setText()`, `setEchoChar()`
B) `getValue()`, `setValue()`, `setText()`
C) `setValue()`, `setChar()`, `setInput()`
D) `getText()`, `setValue()`, `setChar()`

Answer: A) `getText()`, `setText()`, `setEchoChar()`

60 | P a g e
UNIT 1

205. Which layout arranges the components as a deck of cards such that only one component is
visible at a time?
A) BorderLayout
B) FlowLayout
C) CardLayout
D) GridLayout

Answer: C) CardLayout

206. Which layout should you use to organize the components of a container in a tabular form?
A) BorderLayout
B) FlowLayout
C) GridLayout
D) CardLayout

Answer: C) GridLayout

207. Which method executes only once?


A) `start()`
B) `init()`
C) `stop()`
D) `destroy()`

Answer: B) `init()`

208. Which method gets the text associated with Label object `jlbl`?
A) `jlbl.getText()`
B) `getText(jlbl)`
C) `jlbl.getLabelText()`
D) `getLabelText(jlbl)`

Answer: A) `jlbl.getText()`

61 | P a g e
UNIT 1

209. Which method is used to add items to JComboBox?


A) `addItem()`
B) `addItems()`
C) `insertItem()`
D) `setItem()`

Answer: A) `addItem()`

210. Which method is used to add tabs to a JTabbedPane?


A) `addTab()`
B) `setTab()`
C) `insertTab()`
D) `createTab()`

Answer: A) `addTab()`

211. Which method is used to change the size and position of Components?
A) `setDimension()`
B) `resize()`
C) `setBounds(int x, int y, int width, int height)`
D) `setPosition()`

Answer: C) `setBounds(int x, int y, int width, int height)`

212. Which method is used to change the name of a menu item?


A) `setName()`
B) `setLabel()`
C) `setItemName()`
D) `setMenuItem()`

Answer: B) `setLabel()`

62 | P a g e
UNIT 1

213. Which method is used to close a Swing frame?


A) `close()`
B) `exit()`
C) `dispose()`
D) `shutdown()`

Answer: C) `dispose()`

214. Which method is used to display a Label on a checkbox?


A) `setCheckboxText()`
B) `displayLabel()`
C) `setLabelText()`
D) `setLabel()`

Answer: D) `setLabel()`

215. Which method is used to set the label for Button `B`?
A) `setButtonText()`
B) `setCaption()`
C) `setButtonLabel()`
D) `setLabel(String s)`

Answer: D) `setLabel(String s)`

216. Which method is used to set the dimensions of the window?


A) `resize()`
B) `modifySize()`
C) `setSize(int newWidth, int newHeight)`
D) `changeSize()
Answer: C) `setSize(int newWidth, int newHeight)`

63 | P a g e
UNIT 1

217. Which method is used to set the layout of the Applet?


A) `setLayout()`
B) `setAppletLayout()`
C) `applyLayout()`
D) `arrangeLayout()`

Answer: A) `setLayout()`

218. Which method sets the size and position of a component?


A) `modifyPosition()`
B) `setBounds()`
C) `setPosition()`
D) `resizeComponent()`

Answer: B) `setBounds()`

219. Which method will cause a Frame to be displayed?


A) `display()`
B) `show()`
C) `setVisible(true)`
D) `open()`

Answer: C) `setVisible(true)`

220. Which object can be constructed to show and select any number of choices in the visible
window?
A) `Choice`
B) `List`
C) `ComboBox`
D) `Menu`

Answer: B) `List`

64 | P a g e
UNIT 1

221. Which of the following applet tags is legal to embed an applet class named `Test` into a Web
page?
A) `<applet code=Test.class width=200 height=100></applet>`
B) `<<applet code=Test.class width=200 height=100>></applet>`
C) `</applet code=Test.class width=200 height=100>>`
D) `<applet code=Test.class width=200 height=100></applet>`

Answer: A) `<applet code=Test.class width=200 height=100></applet>`

65 | P a g e

You might also like