Starting Out With Java From Control Structures Through Data Structures 2nd Edition Gaddis Test Bank - Free Download Available In PDF DOCX Format
Starting Out With Java From Control Structures Through Data Structures 2nd Edition Gaddis Test Bank - Free Download Available In PDF DOCX Format
https://testbankfan.com/product/starting-out-with-java-from-
control-structures-through-data-structures-2nd-edition-
gaddis-test-bank/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-data-structures-2nd-edition-gaddis-solutions-
manual/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-test-bank/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-solutions-
manual/
https://testbankfan.com/product/computer-and-communication-
networks-2nd-edition-mir-solutions-manual/
Introductory Econometrics Asia Pacific 1st Edition
Wooldridge Test Bank
https://testbankfan.com/product/introductory-econometrics-asia-
pacific-1st-edition-wooldridge-test-bank/
https://testbankfan.com/product/forensic-accounting-and-fraud-
examination-1st-edition-kranacher-test-bank/
https://testbankfan.com/product/basics-of-research-methods-for-
criminal-justice-and-criminology-3rd-edition-maxfield-test-bank/
https://testbankfan.com/product/anatomy-of-orofacial-structures-7th-
edition-brand-test-bank/
https://testbankfan.com/product/essentials-of-entrepreneurship-and-
small-business-management-9th-edition-scarborough-solutions-manual/
College Algebra 4th Edition Blitzer Solutions Manual
https://testbankfan.com/product/college-algebra-4th-edition-blitzer-
solutions-manual/
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
Chapter 7
MULTIPLE CHOICE
1. ________ is a library of classes that do not replace ________, but provide an improved alternative for creating
GUI applications.
a. AWT, Swing
b. Swing, AWT
c. JFC, AWT
d. JFC, Swing
ANS: B
ANS: A
ANS: D
4. To end an application, pass this as the argument to the JFrame class's setDefaultCloseOperation()
method.
a. END_ON_CLOSE
b. JFrame.END_ON_CLOSE
c. JFrame.EXIT_ON_CLOSE
d. JFrame.CLOSE_NOT_HIDE
ANS: C
5. The minimize button, maximize button, and close button on a window are sometimes referred to as
a. operations buttons
b. sizing buttons
c. decorations
d. display buttons
ANS: C
6. To use the ActionListener interface, as well as other event listener interfaces, you must have the following
import statement in your code:
a. import java.swing;
b. import java.awt;
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
c. import java.awt.*;
d. import java.awt.event.*;
ANS: D
7. When you write an action listener class for a JButton component, it must
a. have a method named buttonClicked
b. implement the ActionLIstener interface
c. have a method named actionPerformed which must take an argument of the ActionEvent
type
d. Both b and c.
ANS: D
ANS: B
9. To use the Color class, which is used to set the foreground and background of various objects, use the
following import statement
a. import java.swing;
b. import java.awt;
c. import java.awt.*;
d. import java.awt.event.*;
ANS: C
ANS: C
11. This layout manager arranges components in regions named North, South, East, West, and Center.
a. GridLayout
b. BorderLayout
c. FlowLayout
d. RegionLayout
ANS: B
12. If panel references a JPanel object, which of the following statements adds the GridLayout to it?
a. panel.setLayout(new (GridLayout(2,3));
b. panel.addLayout(new (GridLayout(2,3));
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
c. panel.GridLayout(2,3);
d. panel.attachLayout(GridLayout(2,3));
ANS: A
13. When using the BorderLayout manager, how many components can each region hold?
a. 1
b. 2
c. 5
d. No limit
ANS: A
14. The GridLayout manager limits each cell to only one component. To put two or more components in a cell,
do this.
a. Resize the cells so they can hold more
b. You can nest panels inside the cells, and add other components to the panels
c. The statement is false. The GridLayout manager does not have this restriction
d. Resize the components to fit in the cell
ANS: B
ANS: C
16. How many radio buttons can be selected at the same time as the result of the following code?
a. 1
b. 2
c. 3
d. 4
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
ANS: B
17. Assume that radio references a JRadioButton object. To click the radio button in code, use the following
statement.
a. radio.Click();
b. Click(radio);
c. Click(radio, true);
d. radio.doClick();
ANS: D
18. The variable panel references a JPanel object. The variable bGroup references a ButtonGroup object,
which contains several button components. If you want to add the buttons to the panel...
ANS: D
panel.setBorder(BorderFactory.createLineBorder(Color.BLUE, 5));
a. The JPanel referenced by panel will have a blue line border that is 5 millimeters thick.
b. The JPanel referenced by panel will have a blue line border that is 5 pixels thick.
c. The JPanel referenced by panel will have a blue line border that is 5 characters thick.
d. The JPanel referenced by panel will have a blue line border that is 5 inches thick.
ANS: B
20. When an application uses many components, rather than deriving just one class from the JFrame class, it is
often better to encapsulate smaller groups of related components and their event listeners into their own class. A
commonly used technique to do this is:
a. To extend a class from the JAbstractButton class to contain other components and their
related code
b. To extend a class from the JComponent class to contain other components and their related code
c. To extend a class from the JPanel class to contain other components and their related code
d. To extend a class from the JFrame class to contain other components and their related code
ANS: C
21. To include Swing and AWT components in your program, use the following import statements
a. import java.swing; import java.awt;
b. import java.swing; import javax.awt;
c. import javax.swing; import java.awt;
d. import javax.swing; import javax.awt;
ANS: C
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
22. These types of components are coupled with their underlying peers.
a. Lightweight
b. Featherweight
c. Middleweight
d. Heavyweight
ANS: D
ANS: B
24. When this is the argument passed to the JFrame class's setDefaultCloseOperation() method, the
application is hidden, but not closed.
a. HIDE_ON_CLOSE
b. JFrame. HIDE_ON_CLOSE
c. JFrame.EXIT_ON_CLOSE
d. JFrame.HIDE_NOT_CLOSE
ANS: B
25. This is a basic window that has a border around it, a title bar, and a set of buttons for minimizing, maximizing,
and closing the window.
a. Pane
b. Container
c. Frame
d. Dialog box
ANS: C
26. Which of the following statements creates a class that is extended from the JFrame class?
a. JFrame DerivedClass = new JFrame();
b. class JFrame DerivedClass;
c. JFrame(DerivedClass);
d. public class DerivedClass extends JFrame{}
ANS: D
addButton.addActionListener(new AddButtonListener());
ANS: C
ANS: A
29. If button1 is a JButton object, which of the following statements will make its background blue?
a. button1.makeBackground(BLUE);
b. button1.setBackground(Color.BLUE);
c. button1.makeBackground(Color.BLUE);
d. button1.set.Background(BLUE);
ANS: B
ANS: B
31. Which of the following is not a rule for the FlowLayout manager?
a. Multiple components can be added to a container that uses a FlowLayout manager
b. New components will be added in a row from left to right
c. When there is no more room in a row, additional components are put on the next row
d. All of these are rules for the FlowLayout manager
ANS: D
ANS: C
33. When adding components to a container that is governed by the GridLayout manager,
a. you cannot specify a cell
b. you specify the cell with the row and column numbers in the add statement
c. you must add them starting with the lower, right cell
d. the components are added automatically by filling up the first column, then the second, etc.
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
ANS: A
ANS: D
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ColorCheckBoxWindow extends JFrame
{
private JCheckBox greenCheckBox;
private final int WINDOW_WIDTH = 300, WINDOW_HEIGHT = 100;
public ColorCheckBoxWindow()
{
setTitle("Green Check Box");
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
greenCheckBox = new JCheckBox("Green");
greenCheckBox.addItemListener(new CheckBoxListener());
setLayout(new FlowLayout());
add(greenCheckBox);
setVisible(true);
}
public void itemStateChanged(ItemEvent e)
{
if (e.getSource() == greenCheckBox)
{
System.exit(0);
}
}
}
a. ColorCheckBoxWindow is not implementing the correct listener
b. The button cannot be added to the content pane
c. The itemStateChanged method cannot be coded here
d. greenCheckBox should not be a private member
ANS: C
36. Assume that the variable checkbox references a JCheckBox object. To determine whether the check box has
been selected, use the following code.
a. if (isSelected(checkBox)) {/*code to execute, if selected*/}
b. if (checkBox.isSelected()) {/*code to execute, if selected*/}
c. if (checkBox) {/*code to execute, if selected*/}
d. if (checkBox.doClick()) {/*code to execute, if selected*/}
ANS: B
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
panel.setBorder(BorderFactory.createTitleBorder("Title"));
a. The JPanel referenced by panel will have an etched border with the title "Title" displayed on it.
b. The JPanel referenced by panel will have an empty border with the title "Title" displayed on it.
c. The JPanel referenced by panel will have a line border with the title "Title" displayed on it.
d. The JPanel referenced by panel will have a compound border with the title "Title" displayed on
it.
ANS: A
38. When an application uses many components, instead of extending just one class from the JFrame class, a better
approach is to
a. break the application into several smaller applications
b. reconsider the design of the application
c. encapsulate smaller groups of related components and their event listeners into their own classes
d. just go ahead and do it in one large class
ANS: C
39. This is a graphic image that is displayed while an application loads into memory and starts up.
a. The Java 6 trademark screen
b. Memory usage screen
c. Blue screen of death
d. Splash screen
ANS: D
40. You would use this command at the operating system command line to execute the code in the
MyApplication class and display the graphic image Logo.jpg as a splash screen.
a. java MyApplication Logo.jpg
b. java -splash:Logo.jpg MyApplication
c. java MyApplication –splash
d. java Logo.jpg –splash:MyApplication
ANS: B
TRUE/FALSE
1. A GUI program automatically stops executing when the end of the main method is reached.
ANS: F
2. A common technique for writing an event listener class is to write it as a private inner class inside the class that
creates the GUI.
ANS: T
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 2/e © 2012 Pearson Education
3. The following statement adds the FlowLayout manager to the container, centers the components, and
separates the components with a gap of 10 pixels.
setLayout(new FlowLayout());
ANS: F
ANS: T
ANS: T
6. The ActionEvent argument that is passed to an action listener's actionPerformed method is the event
object that was generated in response to an event.
ANS: T
7. The FlowLayout manager does not allow the programmer to align components.
ANS: F
8. You must use the statement import java.swing.*; in order to use the ItemListener interface.
ANS: F
9. When a splash screen is displayed, the application does not load and execute until the user clicks the splash
screen image with the mouse.
ANS: F
10. In Java, the ability to display splash screens was introduced in Java 6.
ANS: T
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of La lyre
héroïque et dolente
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Language: French
LA LYRE
HÉROÏQUE ET DOLENTE
DE SABLE ET D'OR
LA GLOIRE DU VERBE.—L'ERRANTE
PARIS
SOCIÉTÉ DV MERCVRE DE FRANCE
XV, RVE DE L'ÉCHAVDÉ-SAINT-GERMAIN, XV
M DCCC XCVII
DU MÊME AUTEUR:
EXEMPLAIRE No 1
A MARCEL COLLIÈRE
A Émile Galle.
LE DIEU MORT
A André Fontainas.
A Maurice Nicolle.
SOLITUDE
A Grégoire le Roy.
A Puvis de Chavannes.
L'AUTOMNE A DÉNUDÉ…
A HENRI DE RÉGNIER
PSYCHÉ
II
III
IV
HYMNIS
II
CHRYSARION
L'ERRANTE
A RACHILDE
L'ERRANTE
I. DE SABLE ET D'OR.
L'HOMME
L'HOMME
L'ERRANTE
Non, demeure,
Puisque la volonté de ton sort et du soir
A mené tes pieds las vers le morne manoir
Et vers l'hôte imprévu dressé devant ta face
En qui ta voix a fait s'épanouir, vivace,
Une fleur de jadis aux pistils oubliés.
J'y consens: ô soleils abolis, flamboyez
Encore, surgissez dans ma sombre mémoire
En aube de suprême et cinéraire gloire
Avant que cette chair s'engloutisse à jamais;
Et toi, dolente ombre d'une ombre que j'aimais
Et qui m'a refusé ses lèvres mensongères,
Toi qui dormis sous des étoiles étrangères
Des sommeils flagellés par l'âpre fouet du vent,
Entre sans peur avec un sourire d'enfant
Et l'ingénuité d'une âme puérile
Dans la vieille maison où le hasard t'exile.
L'ERRANTE
Salut,
Seuil, et que les haillons du passé révolu
S'envolent de ma chair au vent qui les emporte
Ainsi qu'un vain linceul d'où jaillit une morte
Pour renaître en splendeur de soleil exalté,
Belle de sa jeunesse et de sa nudité.
II. DE GUEULES.
testbankfan.com