CPSC150 EH26 1

CPSC150 EH26

Q1: Which of the following is not a GUI component (control or widget)?

a. String.

b. Button.

c. Menu.

d. Combo box.

Q2: Which component contains menus?

a. Menu button.

b. Title bar.

c. Menu bar.

d. Combo box.

Q3: Which of the following is the method used to display a dialog box to gather input?

a. showMessageDialog.

b. getInput.

c. inputDialog.

d. showInputDialog.

Q4: The text “Hello there, my friend.” is an example of what type of capitalization?

a. sentence capitalization.

b. sentence-style capitalization.

c. book capitalization.

d. book-title capitalization.

Q5: The JOptionPane constant used to display an icon indicating a prompt is:

a. JOptionPane.ERROR_MESSAGE.

b. JOptionPane.INFORMATION_MESSAGE.

c. JOptionPane.QUESTION_MESSAGE.

d. JOptionPane.WARNING_MESSAGE.

Q6: Which of the following is not true for a JTextField?

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.

Q7: 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.

Q8: Which of the following is not true of Swing GUI components?

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.

Q9: Which of the following is not true of heavyweight components?

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.

Q10: Which pair of words does not complete the sentence below correctly?

A is a .

a. Container, Component.

b. JComponent, Container.

c. Component, Object.

d. Container, JPanel.

Q11: 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.

Q12: 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.

Q13: Which of the following is not true of a JLabel?

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.

Q14: 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 ).

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

a. TERMINATE_ON_CLOSE.

b. IMMEDIATE_CLOSE.

c. EXIT_ON_CLOSE.

d. None of the above.

Q16:

Create the following GUI. You do not have to provide any functionality.