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://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-data-structures-2nd-edition-gaddis-test-bank/
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-data-structures-2nd-edition-gaddis-solutions-
manual/
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-test-bank/
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-solutions-
manual/
https://testbankdeal.com/product/new-products-management-11th-edition-
crawford-solutions-manual/
Exploring Medical Language A Student Directed Approach 9th
Edition Brooks Test Bank
https://testbankdeal.com/product/exploring-medical-language-a-student-
directed-approach-9th-edition-brooks-test-bank/
https://testbankdeal.com/product/fundamentals-of-business-math-
canadian-3rd-edition-jerome-solutions-manual/
https://testbankdeal.com/product/marketing-research-asia-pacific-4th-
edition-zikmund-solutions-manual/
https://testbankdeal.com/product/payroll-accounting-2016-26th-edition-
bieg-solutions-manual/
Management Leading and Collaborating in a Competitive
World 11th Edition Bateman Test Bank
https://testbankdeal.com/product/management-leading-and-collaborating-
in-a-competitive-world-11th-edition-bateman-test-bank/
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:
specious present. The processes by which I think them, however, all
overlap. What events, then, does the specious present seem to
contain? Simply my successive acts of thinking these long-past
things, not the long-past things themselves. As the instantly-present
thought may be of a long-past thing, so the just-past thought may
be of another long-past thing. When a long-past event is reproduced
in memory and conceived with its date, the reproduction and
conceiving traverse the specious present. The immediate content of
the latter is thus all my direct experiences, whether subjective or
objective. Some of these meanwhile may be representative of other
experiences indefinitely remote.
The number of these direct experiences which the specious present
and immediately-intuited past may embrace measures the extent of
our 'primary,' as Exner calls it, or, as Richet calls it, of our
'elementary' memory.[561] The sensation resultant from the
overlapping is that of the duration which the experiences seem to
fill. As is the number of any larger set of events to that of these
experiences, so we suppose is the length of that duration to this
duration. But of the longer duration we have no direct 'realizing
sense.' The variations in our appreciation of the same amount of real
time may possibly be explained by alterations in the rate of fading in
the images, producing changes in the complication of superposed
processes, to which changes changed states of consciousness may
correspond. But however long we may conceive a space of time to
be, the objective amount of it which is directly perceived at any one
moment by us can never exceed the scope of our 'primary memory'
at the moment in question.[562]
We have every reason to think that creatures may possibly differ
enormously in the amounts of duration which they intuitively feel,
and in the fineness of the events that may fill it. Von Bær has
indulged[563] in some interesting computations of the effect of such
differences in changing the aspect of Nature. Suppose we were able,
within the length of a second, to note 10,000 events distinctly,
instead of barely 10, as now; if our life were then destined to hold
the same number of impressions, it might be 1000 times as short.
We should live less than a month, and personally know nothing of
the change of seasons. If born in winter, we should believe in
summer as we now believe in the heats of the Carboniferous era.
The motions of organic beings would be so slow to our senses as to
be inferred, not seen. The sun would stand still in the sky, the moon
be almost free from change, and so on. But now reverse the
hypothesis and suppose a being to get only one 1000th part of the
sensations that we get in a given time, and consequently to live
1000 times as long. Winters and summers will be to him like
quarters of an hour. Mushrooms and the swifter-growing plants will
shoot into being so rapidly as to appear instantaneous creations;
annual shrubs will rise and fall from the earth like restlessly boiling-
water springs; the motions of animals will be as invisible as are to us
the movements of bullets and cannon-balls; the sun will scour
through the sky like a meteor, leaving a fiery trail behind him, etc.
That such imaginary cases (barring the superhuman longevity) may
be realized somewhere in the animal kingdom, it would be rash to
deny.
CHAPTER XVI.
MEMORY.
In the last chapter what concerned us was the direct intuition of
time. We found it limited to intervals of considerably less than a
minute. Beyond its borders extends the immense region of
conceived time, past and future, into one direction or another of
which we mentally project all the events which we think of as real,
and form a systematic order of them by giving to each a date. The
relation of conceived to intuited time is just like that of the fictitious
space pictured on the flat back-scene of a theatre to the actual
space of the stage. The objects painted on the former (trees,
columns, houses in a receding street, etc.) carry back the series of
similar objects solidly placed upon the latter, and we think we see
things in a continuous perspective, when we really see thus only a
few of them and imagine that we see the rest. The chapter which
lies before us deals with the way in which we paint the remote past,
as it were, upon a canvas in our memory, and yet often imagine that
we have direct vision of its depths.
The stream of thought flows on; but most of its segments fall into
the bottomless abyss of oblivion. Of some, no memory survives the
instant of their passage. Of others, it is confined to a few moments,
hours, or days. Others, again, leave vestiges which are
indestructible, and by means of which they may be recalled as long
as life endures. Can we explain these differences?
PRIMARY MEMORY.
"Suppose you have seen Mevius in the temple, but now afresh
in Titus' house. I say you recognize Mevius, that is, are
conscious of having seen him before because, although now you
perceive him with your senses along with Titus' house, your
imagination produces an image of him along with one of the
temple, and of the acts of your own mind reflecting on Mevius
in the temple. Hence the idea of Mevius which is reproduced in
sense is contained in another series of perceptions than that
which formerly contained it, and this difference is the reason
why we are conscious of having had it before.... For whilst now
you see Mevius in the house of Titus, your imagination places
him in the temple, and renders you conscious of the state of
mind which you found in yourself when you beheld him there.
By this you know that you have seen him before, that is, you
recognize him. But you recognize him because his idea is now
contained in another series of perceptions from that in which
you first saw him."[577]
MEMORY'S CAUSES.
"There is," he says, "a state of mind familiar to all men, in which
we are said to remember. In this state it is certain we have not
in the mind the idea which we are trying to have in it.[579] How
is it, then, that we proceed in the course of our endeavor, to
procure its introduction into the mind? If we have not the idea
itself, we have certain ideas connected with it. We run over
those ideas, one after another, in hopes that some one of them
will suggest the idea we are in quest of; and if any one of them
does, it is always one so connected with it as to call it up in the
way of association. I meet an old acquaintance, whose name I
do not remember, and wish to recollect. I run over a number of
names, in hopes that some of them may be associated with the
idea of the individual. I think of all the circumstances in which I
have seen him engaged; the time when I knew him, the
persons along with whom I knew him, the things he did, or the
things he suffered; and, if I chance upon any idea with which
the name is associated, then immediately I have the
recollection; if not, my pursuit of it is vain.[580] There is another
set of cases, very familiar, but affording very important evidence
on the subject. It frequently happens that there are matters
which we desire not to forget. What is the contrivance to which
we have recourse for preserving the memory—that is, for
making sure that it will be called into existence, when it is our
wish that it should? All men invariably employ the same
expedient. They endeavor to form an association between the
idea of the thing to be remembered, and some sensation, or
some idea, which they know beforehand will occur at or near
the time when they wish the remembrance to be in their minds.
If this association is formed, and the association or idea with
which it has been formed occurs; the sensation, or idea, calls up
the remembrance; and the object of him who formed the
association is attained. To use a vulgar instance: a man receives
a commission from his friend, and, that he may not forget it,
ties a knot in his handkerchief. How is this fact to be explained?
First of all, the idea of the commission is associated with the
making of the knot. Next, the handkerchief is a thing which it is
known beforehand will be frequently seen, and of course at no
great distance of time from the occasion on which the memory
is desired. The handkerchief being seen, the knot is seen, and
this sensation recalls the idea of the commission, between
which and itself the association had been purposely formed."
[581]
The remembered fact being n, then, the path N—O is what arouses
for n its setting when it is recalled, and makes it other than a mere
imagination. The path M—N, on the other hand, gives the cue or
occasion of its being recalled at all. Memory being this altogether
conditioned on brain-paths, its excellence in a given individual will
depend partly on the number and partly on the persistence of these
paths.
The persistence or permanence of the paths is a physiological
property of the brain-tissue of the individual, whilst their number is
altogether due to the facts of his mental experience. Let the quality
of permanence in the paths be called the native tenacity, or
physiological retentiveness. This tenacity differs enormously from
infancy to old age, and from one person to another. Some minds are
like wax under a seal—no impression, however disconnected with
others, is wiped out. Others, like a jelly, vibrate to every touch, but
under usual conditions retain no permanent mark. These latter
minds, before they can recollect a fact, must weave it into their
permanent stores of knowledge. They have no desultory memory.
Those persons, on the contrary, who retain names, dates and
addresses, anecdotes, gossip, poetry, quotations, and all sorts of
miscellaneous facts, without an effort, have desultory memory in a
high degree, and certainly owe it to the unusual tenacity of their
brain-substance for any path once formed therein. No one probably
was ever effective on a voluminous scale without a high degree of
this physiological retentiveness. In the practical as in the theoretic
life, the man whose acquisitions stick is the man who is always
achieving and advancing, whilst his neighbors, spending most of
their time in relearning what they once knew but have forgotten,
simply hold their own. A Charlemagne, a Luther, a Leibnitz, a Walter
Scott, any example, in short, of your quarto or folio editions of
mankind, must needs have amazing retentiveness of the purely
physiological sort. Men without this retentiveness may excel in the
quality of their work at this point or at that, but will never do such
mighty sums of it, or be influential contemporaneously on such a
scale.[585]
But there comes a time of life for all of us when we can do no more
than hold our own in the way of acquisitions, when the old paths
fade as fast as the new ones form in our brain, and when we forget
in a week quite as much as we can learn in the same space of time.
This equilibrium may last many, many years. In extreme old age it is
upset in the reverse direction, and forgetting prevails over
acquisition or rather there is no acquisition. Brain-paths are so
transient that in the course of a few minutes of conversation the
same question is asked and its answer forgotten half a dozen times.
Then the superior tenacity of the paths formed in childhood
becomes manifest: the dotard will retrace the facts of his earlier
years after he has lost all those of later date.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
testbankdeal.com