Java How to Program, 11/e Multiple Choice Test Bank 1 of 4
Chapter 35: GUI, Part 2
Section 35.2 JSlider
35.2 Q1: A JSlider cannot display which of the following:
a. Major tick marks.
b. Minor tick marks labels.
c. Minor tick marks.
d. Snap-to ticks.
35.2 Q2: Arrow keys can manipulate a JSlider object. Which of the following statements does not correctly
describe how the arrow keys are used?
a. The left-arrow and right arrow keys decrease or increase (respectively) the thumb of the JSlider by 1.
b. The down-arrow and up-arrow keys decrease or increase (respectively) the thumb of the JSlider by 1.
c. The PgDn and PgUp keys decrease or increase (respectively) by block increments of one-tenth of the range
of values.
d. The Home key and End key move the thumb to the maximum or minimum (respectively) value of the
JSlider.
35.2 Q3: JSliders generate what type of event?
a. ActionEvents.
b. ChangeEvents.
c. WindowEvents.
d. MouseEvents.
Section 35.3 Understanding Windows in Java
35.3 Q1: A JFrame supports three operations when the user closes the window. Which of the choices below is not
one of the three:
a. DISPOSE_ON_CLOSE.
b. DO_NOTHING_ON_CLOSE.
c. LOWER_ON_CLOSE.
d. HIDE_ON_CLOSE.
35.3 Q2: Which of the following is not one of the seven methods for handling window events?
a. windowClosing.
b. windowClosed.
c. windowOpening.
d. windowOpened.
35.3 Q3: Which of the following is false?
a. JFrame is a lightweight component.
b. JFrame is a subclass of Frame (which is a subclass of Window).
c. JFrames have a title bar and a border.
d. A JFrame window will look like all other windows displayed on that platform.
35.3 Q4: What happens if setSize is not called on a window?
a. The window is displayed at its preferred size.
b. It is a syntax error.
Java How to Program, 11/e Multiple Choice Test Bank 2 of 4
c. The window is not displayed.
d. Only the title bar appears.
Section 35.4 Using Menus with Frames
35.4 Q1: Which of the choices below do not complete the following sentence correctly?
A _________ is a ___________.
a. JMenuBar, JComponent.
b. JMenuItem, AbstractButton.
c. JMenu, JMenuItem.
d. JRadioButtonMenuItem, JMenu.
35.4 Q2: Menus are attached to windows by calling method ________.
a. addMenuBar.
b. setJMenuBar.
c. setMenu.
d. addJMenuBar.
35.4 Q3: Mnemonics can be used with all subclasses of which class?
a. AbstractButton.
b. JMenu.
c. JMenuItem
d. JComponent.
35.4 Q4: The first argument to method showMessageDialog specifies ________.
a. the title.
b. the message.
c. the icon.
d. the parent window.
Section 35.5 JPopupMenu
35.5 Q1: Which statement below is false?
a. Each JPopupMenu should be associated with its own component.
b. Local variables must be declared static to be used in an anonymous inner class declaration.
c. The JPopupMenu show method specifies the origin component, and the coordinates at which the JPopupMenu
should display on the component.
d. None of the above.
35.5 Q2: Which method returns true if the popup trigger event occurred?
a. isTrigger.
b. isPopup.
c. isPopupTrigger.
d. isTriggerEvent.
Section 35.6 Pluggable Look-and-Feel
Java How to Program, 11/e Multiple Choice Test Bank 4 of 4
© Copyright 1992-2018 by Deitel & Associates, Inc. and Pearson Education, Inc.
ANS: a. top.
Section 35.9 BoxLayout Layout Manager
35.9 Q1: To evenly distribute fixed-size components in a row using BoxLayout, use the method ________.
a. createVerticalStrut()
b. createHorizontalStrut()
c. createVerticalGlue()
d. createHorizontalGlue()
35.9 Q2: To create a fixed space between all components using BoxLayout, use the method ________.
a. createVerticalStrut()
b. createHorizontalStrut()
c. createGlue()
d. createRigidArea()
Section 35.10 GridBagLayout Layout Manager
35.10 Q1: Which of the following GridBagConstraints specifies the number of columns a component will occupy?
a. gridwidth.
b. gridheight.
c. weightx.
d. weighty.
35.10 Q2: What is the default value for the GridBagConstraint fill?
a. NONE.
b. BOTH.
c. CENTER.
d. HORIZONTAL.
GridBagConstraints constants RELATIVE and REMAINDER
35.10 Q3: What GridBagConstraints constants can be used in place of gridx and gridy?
a. RELATIVE and REMAINDER.
b. CENTER and BOTH.
c. NORTH and SOUTH.
d. FILL and NONE.
35.10 Q4: The GridBagContraints constant RELATIVE means that ________.
a. the component is the last component.
b. the component is the next to last component.
c. the component should be placed relative to the previous component.
d. Both b and c.