Intro to Java Test #4

¡Supera tus tareas y exámenes ahora con Quizwiz!

D. add

A JLabel can be attached to a JFrame using method: A. attach B. contain C. append D. add

B. normally several JRadioButtons are grouped together and are mutually exclusive.

A JRadioButton is different from a JCheckBox in that _______ . A. a JRadioButton is a subclass of JToggleButton, JCheckBox is not. B. normally several JRadioButtons are grouped together and are mutually exclusive. C. a JRadioButton is a type of button, JCheckBox is not. D. a JRadioButton is a state button, JCheckBox is not.

C. results in a compilation error.

Adding a ButtonGroup object to a container: A. is necessary for the functionality of the ButtonGroup to work properly. B. causes all the JRadioButtons in the group to have their event handlers registered. C. results in a compilation error. D. None of the above.

B. listenerList

Every JComponent has an instance variable called ________ that enables the object to maintain references to all its registered listeners. A. registeredListenerList B. listenerList C. registeredList D. eventListenerList

A. events of that type to be ignored

Forgetting to register an event-handler object for a particular GUI component's event type causes ________. A. events of that type to be ignored B. all of the GUI component's events to be ignored C. a compilation error D. None of the above

C. one or more

How many event-listener interfaces correspond to each event type? A. one B. two C. one or more D. zero

B. getPassword

JPasswordField contains method ________ to obtain the data entered. A. getInput B. getPassword C. getText D. getEcho

B. setLayout

Method ________ can be used to set the layout manager of a container. A. setManager B. setLayout C. setLayoutManager D. setGUILayout

D. All of the above

Some common lightweight component features supported by JComponent include: A. support for user-interface localization B. shortcut keys C. tool tips D. All of the above

D. event source

The GUI event with which the user interacts is the_________ . A. event effector B. event container C. event raiser D. event source

C. JOptionPane.QUESTION_MESSAGE

The JOptionPane constant used to display an icon prompting the user for input is: A. JOptionPane.ERROR_MESSAGE B. JOptionPane.INFORMATION_MESSAGE C. JOptionPane.QUESTION_MESSAGE D. JOptionPane.WARNING_MESSAGE

D. ButtonGroup

The logical relationship between radio buttons is maintained by objects of what class? A. MutualExclusionGroup B. RadioButtonGroup C. Group D. ButtonGroup

C. Change the button icon

The method setRolloverIcon is used to: A. Handle a key event B. Change the button text C. Change the button icon D. All of the above

B. JComboBox

The setMaximumRowCount method is used for: A. Button B. JComboBox C. JRadioButton D. JToggleButton

A. sentence-style capitalization

The text "Hello there, my friend." is an example of what type of capitalization? A. sentence-style capitalization B. book-title capitalization C. Neither of the above D. Both of the above

B. look-and-feel

Together, the appearance and the way in which the user interacts with the application are known as that application's ________. A. abstract window toolkit B. look-and-feel C. swing factor D. All of the above

D. The JComboBox expands to a list

When the arrow on a JComboBox is clicked: A. an ItemEvent occurs B. a scrollbar always appears C. an ActionEvent occurs D. The JComboBox expands to a list

C. ItemEvent

When the user clicks a JCheckBox, a(n)_______ occurs. A. CheckedEvent B. ButtonEvent C. ItemEvent D. ActionEvent

A. ActionEvent, ActionListener

When the user presses Enter in a JPasswordField, the GUI component generates an , which is processed by an object that implements the interface . A. ActionEvent, ActionListener B. ActionEvent, ActionEventListener C. TextEvent, TextListener D. TextEvent, TextEventListener

C. EXIT_ON_CLOSE

Which JFrame constant indicates that the program should terminate when the window is closed by the user? A. TERMINATE_ON_CLOSE B. IMMEDIATELY_CLOSE C. EXIT_ON_CLOSE D. All of the above

C. Menu Bar

Which component contains menus? A. Menu button B. Title bar C. Menu bar D. Combo box

B. getResource( "file.txt" )

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" )

A. isSelected

Which method determines if a JCheckBox is selected? A. isSelected B. getSelected C. selected D. None of the above

D. setToolTipText

Which method sets the text that's displayed when the user hovers over a JLabel? A. setHover B. setHoverText C. setToolTip D. setToolTipText

A. getIcon, setIcon

Which methods retrieve and set the image that's displayed in a JLabel? A. getIcon, setIcon B. getResource, setResource C. getText, setText D. getImageIcon, setImageIcon

D. Cannot be declared private.

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. JButton, AbstractButton

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. ContainerEvent, ComponentEvent

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

C. Viewing the text in a label

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

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

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 )

D. JPasswordFields generate events; JTextFields do not

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

A. String

Which of the following is not a GUI component (control or widget)? A. String B. Button C. Menu D. Combo box

D. All of the above are types of buttons

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. The appropriate interface must be registered

Which of the following is not necessary to use the event delegation model? A. 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

A. JButton

Which of the following is stateless? A. JButton B. JToggleButton C. JRadioButton D. JCheckBox

D. showInputDialog

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. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

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. Correct! D. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

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

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.

C. A JLabel can display text and a button

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. JLabel is a subclass of JComponent

C. They are declared with the anonymous keyword.

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.

A. AWT components are not heavyweight components

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

D. Displays a list of fields

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

B. textField.setEditable( false );

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. Container, JPanel

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. JFrame

__________ 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. A. JLabel B. JFrame C. JSwing D. JWindowControl


Conjuntos de estudio relacionados

Psychology Module 11 Quiz Questions

View Set

ANP 2 test 3 fluid, electrolyte, and acid base balance

View Set

Applied Managerial Finance Midterm

View Set

Ch. 13-15 Review for Unit 4 AP World

View Set