OOP Ch. 14

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

When the user presses Enter in a JPasswordField, the GUI component generates an _______ , which is processed by an object that implements the interface ______ .

ActionEvent, ActionListener.

A user of a one-button mouse can simulate pushing the middle button on a three-button mouse by holding the _____ while clicking the left mouse button.

Alt key.

Which layout manager is the default for JFrame?

BorderLayout.

The logical relationship between radio buttons is maintained by objects of what class?

ButtonGroup

Which region is used by default when a Component is added to a BorderLayout?

CENTER.

The method setRolloverIcon is used to:

Change the button icon.

Which JFrame constant indicates that the program should terminate when the window is closed by the user?

EXIT_ON_CLOSE.

When the user clicks a JCheckBox, a(n) _____ occurs.

ItemEvent

The setMaximumRowCount method is used for:

JComboBox.

______ provides the basic attributes and behaviors of a window—a title bar at the top of the window, and buttons to minimize, maximize and close the window.

JFrame

The JOptionPane constant used to display an icon prompting the user for input is:

JOptionPane.QUESTION_MESSAGE.

All layout managers implement the interface:

LayoutManager.

BorderLayout implements interface:

LayoutManager2.

Consider the list below: January February March April May June July August September October November December What type of JList selection mode would allow the user to select March, June and July in one step?

MULTIPLE_INTERVAL_SELECTION.

Which component contains menus?

Menu bar

A MouseHandler object implements which two interfaces?

MouseListener and MouseMotionListener.

When the arrow on a JComboBox is clicked:

The JComboBox expands to a list.

In what cases are adapter classes useful?

When it is not desirable to declare every method in the event-listener interface.

Selecting a JList item generates:

a ListSelectionEvent.

The class GridLayout constructs _______ to hold components.

a grid with multiple rows and columns.

Method paintComponent is called when:

a lightweight Swing component is displayed.

Which of the following statements about heavyweight components is false? a. AWT components are not heavyweight components. b. Several Swing components are heavyweight components. c. The look-and-feel may vary across platforms. d. The functionality may vary across platforms.

a. AWT components are not heavyweight components.

Which of the following is stateless? a. JButton. b. JToggleButton. c. JRadioButton. d. JCheckBox.

a. JButton

Which of the following is not a GUI component (control or widget)? a. String. b. Button. c. Menu. d. Combo box.

a. String

Which of the following statements about Swing GUI components is false? a. Swing components are less portable but more flexible than the original Java GUI components from package java.awt. b. Most Swing components are written completely in Java. c. Swing components allow the user to specify a uniform look-and-feel across all platforms. d. Swing components allow the user to change the look-and-feel while the program is running.

a. Swing components are less portable but more flexible than the original Java GUI components from package java.awt.

Which of the following expressions creates a JLabel that displays the text "Here is what I look like!" The JLabel should display Icon object face, and the JLabel's contents should be left aligned. a. new JLabel( "Here is what I look like!", face, SwingConstants.LEFT ) b. new JLabel( "Here is what I look like!", face, SwingJustification.LEFT ) c. new JLabel( "Here is what I look like!", SwingConstants.LEFT, face ) d. new JLabel( "Here is what I look like!", SwingJustification.LEFT, face )

a. new JLabel( "Here is what I look like!", face, SwingConstants.LEFT )

Some common lightweight component features supported by JComponent include:

a. support for user-interface localization. b. shortcut keys. c. tool tips.

A JLabel can be attached to a JFrame using method:

add

Method getSelectedValues of class JList returns:

an array of Objects representing the selected items.

Class Point represents:

an x-y coordinate

Which of the following objects cannot trap mouse events? a. JTextField. b. ButtonGroup. c. JButton. d. JComponent.

b. ButtonGroup.

Which pair of words does not complete the sentence below correctly? A ________ is a ________. a. Container, Component. b. Container, JPanel. c. JComponent, Container. d. Component, Object.

b. Container, JPanel.

Which expression returns the location of a file as a URL? a. getURL( "file.txt" ). b. getResource( "file.txt" ). c. findResource( "file.txt" ). d. getClass( "file.txt" ).

b. getResource( "file.txt" ).

Which of the following statements makes the text in a JTextField uneditable? a. textField.setEditable( true ); b. textField.setEditable( false ); c. textField.setUneditable( true ); d. textField.setUneditable( false );

b. textField.setEditable( false );

Which of the following statements about a JLabel is false? a. Applications rarely change a label's contents after creating it. b. A JLabel can display text and an image. c. A JLabel can display text and a button. d. A JLabel is a subclass of JComponent.

c. A JLabel can display text and a button.

Which of the following statements about anonymous inner classes is false? a. They are declared without a name. b. They typically appear inside a method declaration. c. They are declared with the anonymous keyword. d. They can access their top-level class's members.

c. They are declared with the anonymous keyword.

Which of the following does not generate GUI events? a. Typing in a text field. b. Selecting an item from a menu. c. Viewing the text in a label. d. Moving the mouse.

c. Viewing the text in a label.

Which of the following is not a KeyListener method? a. keyPressed. b. keyReleased. c. keyClicked. d. keyTyped.

c. keyClicked.

Which of the following is a MouseMotionListener method? a. mousePressed. b. mouseExited. c. mouseDragged. d. mouseClicked.

c. mouseDragged.

Using layout managers:

can be faster than creating a GUI with absolute positioning.

Which of the following statements about adapters is false? a. An adapter class implements an interface. b. An adapter class provides a default (empty) implementation of every method in the interface. c. Programmers override selected adapter methods. d. A ComponentListener is a ComponentAdaptor.

d. A ComponentListener is a ComponentAdaptor.

Which of the following statements about JPanels is false? a. A JPanel is a JComponent. b. A JPanel is a Container. c. A JPanel does not have a content pane. d. A JPanel has a fixed size.

d. A JPanel has a fixed size.

Which of the following is not a type of button? a. command buttons. b. toggle buttons. c. check boxes. d. All of the above are types of buttons.

d. All of the above are types of buttons.

14.7 Q2: Which of the following completes the sentence below correctly? A(n) ______ is a(n) ________. a. InputEvent, MouseEvent. b. ActionEvent, AdjustmentEvent. c. FocusEvent, WindowEvent. d. ContainerEvent, ComponentEvent.

d. ContainerEvent, ComponentEvent.

Which of the following most completely describes the steps for setting up event handling for a GUI component? a. Create a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler. b. Implement an appropriate event-listener interface and register the event handler. c. Create a class that represents the event handler and implement an appropriate event-listener interface. d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

Which of the following statements for a JTextField is false? a. Can be used to display uneditable text. b. Can be used to display editable text. c. Enables users to enter data from the keyboard. d. Displays a list of fields.

d. Displays a list of fields.

Which of the following choices completes the sentence correctly? A(n) _______ is a(n) _______. a. JToggleButton, JCheckBox. b. JToggleButton, JRadioButton. c. JButton, JToggleButton. d. JButton, AbstractButton.

d. JButton, AbstractButton.

Which of the following is false? a. A JPasswordField shows that characters are being entered, but hides the actual character with an echo character. b. Class JTextField extends JTextComponent; Class JPasswordField extends JTextField. c. Both JTextFields and JPasswordFields are single-line areas in which the user can enter text via the keyboard. d. JPasswordFields generate events; JTextFields do not.

d. JPasswordFields generate events; JTextFields do not.

A JScrollPane is provided automatically for which of the following? a. JToggleButton. b. JRadioButton. c. JList. d. None of the above.

d. None of the above.

Which of the following is not necessary to use the event delegation model? An event listener must be registered. b. An event handler must be implemented. c. The appropriate interface must be implemented. d. The appropriate interface must be registered.

d. The appropriate interface must be registered.

Which of the following answers does not complete the sentence correctly? An anonymous inner class _______ . . a. is frequently used for GUI event handling. b. is non-static. c. does not need a handle to its outer class to access its methods and variables. d. cannot be declared private..

d. cannot be declared private.

Which of the following is the method used to display a dialog box to gather input? a. showMessageDialog. b. getInput. c. inputDialog. d. showInputDialog.

d. showInputDialog

The BorderLayout layout manager:

divides an area into five regions: NORTH, SOUTH, EAST, WEST and CENTER.

The GUI event with which the user interacts is the _____.

event source.

Forgetting to register an event-handler object for a particular GUI component's event type causes _____.

events of that type to be ignored.

When components are added to a container with a GridLayout, the component:

fills the next spot in the row, continuing in the first position of the next row if the current row is full.

Which methods retrieve and set the image that's displayed in a JLabel?

getIcon, setIcon

JPasswordField contains method _____ to obtain the data entered.

getPassword.

Which MouseEvent method can be used to determine if the Alt key is pressed?

isAltDown.

Which method determines if a JCheckBox is selected?

isSelected

Every JComponent has an instance variable called ______ that enables the object to maintain references to all its registered listeners.

listenerList

Together, the appearance and the way in which the user interacts with the application are known as that application's ______.

look-and-feel

The Shift key is a(n) ______ key.

modifier

14.10 Q2: A JRadioButton is different from a JCheckBox in that _______.

normally several JRadioButtons are grouped together and are mutually exclusive.

How many event-listener interfaces correspond to each event type?

one or more

By default JScrollPane:

only displays scrollbars if they are needed.

Each container can have:

only one layout manager.

When a component is______, paintComponent clears the component's background before the component is displayed.

opaque.

A JTextArea:

provides an area for manipulating multiple lines of text.

Method ________ indicates that a Component should be refreshed on screen as soon as possible with a call to that control's paintComponent method.

repaint.

Adding a ButtonGroup object to a container:

results in a compilation error.

Class JTextArea's getSelectedText method:

returns the selected text in the JTextArea.

The text "Hello there, my friend." is an example of what type of capitalization?

sentence-style capitalization

FlowLayout method ______ changes the alignment for the FlowLayout.

setAlignment

Which methods can be used to change the scrollbar policies?

setHorizontalScrollBarPolicy, setVerticalScrollBarPolicy.

Method _______ can be used to set the layout manager of a container.

setLayout

Which method sets the text that's displayed when the user hovers over a JLabel?

setToolTipText

Method getSelectedIndex of class JComboBox returns:

the index of the selected item in the JComboBox.

FlowLayout is:

the simplest layout manager.


संबंधित स्टडी सेट्स

Bio 2 U2S3: membrane structure and function homework

View Set

Prep Ear Assessment for Advanced and Specialty Practice

View Set

Chapter 2 National Differences in Political Economy PPT

View Set

Programming Principles II Final Exam

View Set

Economics & Pers Finance B - Types of Insurance

View Set