Starting Out With Java From Control Structures Through Data Structures 2nd Edition Gaddis Test Bank instant download
Starting Out With Java From Control Structures Through Data Structures 2nd Edition Gaddis Test Bank instant download
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
Random documents with unrelated
content Scribd suggests to you:
First Baptist Church
On your left, at Monument Avenue and the Boulevard, is First Baptist
Church, one of Richmond’s numerous large churches.
21
Jackson Monument
This monument to Thomas J. (“Stonewall”) Jackson, the sculpture for
which is the work of F. William Sievers, shows him mounted on
“Sorrel,” facing north, because he so resolutely opposed the Northern
army. Jackson, whose brilliant strategy is studied today by soldiers
the world over, was a stern, Cromwellian type of commander in
strange contrast to the dashing Stuart. Lee called him his “right arm,”
and no one has ever been able to estimate the severity of the blow
his death dealt the Southern cause. ¶ Continue westward on
Monument to Belmont.
Maury Monument
Commodore Matthew Fontaine Maury (F. William Sievers was the
sculptor for this monument), is not as well known to the average
citizen as he deserves to be, but sailors on all the seas know his work
and are grateful for it. He is known as “The Pathfinder of the Seas”
because he charted the oceans with such accuracy that even today
the Pilot Charts issued by the Hydrographic Office of the Navy
Department are founded on his researches. In the house which still
stands close to the present Valentine Museum, Maury, seeking ways
that would enable his pathetically small Confederate Navy to be
effective against the Union gunboats, invented the submarine
electrical torpedo. ¶ U-turn around the monument; proceed eastward
on Monument one block to Sheppard; right on Sheppard three blocks
to Kensington; proceed left on Kensington to the Boulevard; turn
right.
Battle Abbey, Confederate Memorial Institute
Battle Abbey 22
The Battle Abbey, or Confederate Memorial Institute, houses a
large collection of portraits of Confederate officers, and collections of
Confederate battle flags, arms and equipment, but is chiefly
distinguished for its very beautiful series of mural paintings of
Confederate scenes by the French artist, Charles Hoffbauer. The artist
had done much of his preliminary work when he was called back to
fight for France in 1914. When he returned to Richmond after the
war, Hoffbauer painted out all he had previously done and painted
war as only one who had been through it could. Since 1946 the
Abbey has been the property of the Virginia Historical Society. ¶
Proceed on the Boulevard to Grove.
Virginia House
Virginia House
Agecroft Hall
Agecroft was originally built in Lancashire, England, about 1393,
brought to Richmond and faithfully rebuilt here in 1925. The old
plaster and timber house was the seat of the Langleys, a branch of
the royal Plantagenets. Some of its most beautiful features are an
oriel window and the great hall with gallery for minstrels, paneled
with oak and lighted by stained glass windows. The house is
eventually to go to the city as a generously endowed art museum. ¶
Return to Cary Street Road, turn left, proceed westward to Wilton
Road, turn left, proceed to entrance to Wilton (marked) at end of
thoroughfare.
Country Club of Virginia
Wilton
This stately house was built in 1753 for William Randolph III on a site
overlooking the James about six miles below Richmond. The Colonial
Dames of America in the State of Virginia bought it several years ago
to save the beautiful paneling from being sold out of Virginia, 25
and had it faithfully rebuilt here on another site overlooking the
James. ¶ Return to Cary Street Road, turn left and proceed westward
to intersection of Cary Street Road and Three Chopt Road.
University of Richmond
Social Center and Gymnasium · University of Richmond
26
Columbus Monument
This monument was erected by the Italians of Richmond. The park
includes tennis courts, playgrounds, acres of woodland, and a small
boating lake to your left. Southeast of this point lies Shields Lake, the
mecca of Richmond swimmers in the summer, and beyond that
“Maymont,” the city’s most beautiful park. ¶ Turn right, proceed
around reservoir.
Monroe Park 27
Richmond’s Civic Center (The Mosque)
On the right is one of the many municipal parks, most of which are
located outside the heavily built-up part of the city. Looking through
the park you can see Richmond’s Civic Center, The Mosque, where
conventions, exhibitions, concerts and other events are held. It
contains an auditorium seating 5,000 persons. ¶ Proceed eastward on
Franklin, halting between Madison and Henry Streets.
Commonwealth Club
Here at “The Commonwealth,” the mid-town men’s club of the city,
the Richmond German Club gives the “Germans,” which are the most
formal and unusual features of Richmond’s social life, somewhat
comparable to the Philadelphia Assemblies and Charleston’s St.
Cecilias. ¶ Continue eastward on Franklin to First Street.
City Library
The modern building on the southeast corner is the main City Library,
a gift to the city, of the late James H. Dooley. It was built in 1930 on
the site of the birthplace of James Branch Cabell, Virginia author. The
library has nearly 200,000 catalogued volumes, pamphlets,
periodicals, recordings and sheet music. ¶ Continue eastward on
Franklin, halting briefly between Second and Third Streets.
28
City Library
Woman’s Club
The Woman’s Club has preserved this comfortable nineteenth century
home by adding a larger auditorium at the back and making it their
clubhouse, where are heard many of the distinguished lecturers and
artists of today.
* * * * * * *
29
Richmond Ideal for Conventions
* * * * * * *
RICHMOND TODAY!
30
The Williamsburg-Yorktown-Jamestown
Area
The Governor’s Palace at Williamsburg
32
THE JEFFERSON
The Jefferson is located just outside the noisy section of the city, yet
within easy walking distance of theatres, shopping district and
financial section. It is convenient to all forms of transportation. Free
parking space is provided. Rates range from $3.50.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
testbankfan.com