Starting Out with Java From Control Structures through Objects 5th Edition Tony Gaddis Test Bank download
Starting Out with Java From Control Structures through Objects 5th Edition Tony Gaddis Test Bank download
https://testbankfan.com/product/starting-out-with-java-from-
control-structures-through-objects-5th-edition-tony-gaddis-test-
bank/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-objects-5th-edition-tony-gaddis-solutions-manual/
https://testbankfan.com/product/starting-out-with-c-from-control-
structures-through-objects-7th-edition-tony-gaddis-test-bank/
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-objects-6th-edition-gaddis-test-bank/
https://testbankfan.com/product/fundamentals-of-financial-
accounting-6th-edition-phillips-test-bank/
CDN ED Biology Exploring the Diversity of Life 2nd Edition
Russell Solutions Manual
https://testbankfan.com/product/cdn-ed-biology-exploring-the-
diversity-of-life-2nd-edition-russell-solutions-manual/
https://testbankfan.com/product/finite-element-analysis-theory-and-
application-with-ansys-4th-edition-moaveni-solutions-manual/
https://testbankfan.com/product/intermediate-accounting-volume-2-7th-
edition-beechy-test-bank/
https://testbankfan.com/product/biology-1st-edition-brooker-solutions-
manual/
https://testbankfan.com/product/medical-terminology-simplified-5th-
edition-gylys-test-bank/
Essentials of Contemporary Management Canadian 5th Edition
Jones Solutions Manual
https://testbankfan.com/product/essentials-of-contemporary-management-
canadian-5th-edition-jones-solutions-manual/
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education
Chapter 6
MULTIPLE CHOICE
ANS: B
2. Class objects normally have __________ that perform useful operations on their data, but primitive variables do
not.
a. fields
b. instances
c. methods
d. relationships
ANS: C
3. In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies.
a. object; classes
b. class; objects
c. class; fields
d. attribute; methods
ANS: B
ANS: D
5. When you are working with a ____________, you are using a storage location that holds a piece of data.
a. primitive variable
b. reference variable
c. numeric literal
d. binary number
ANS: A
ANS: B
ANS: C
8. Java allows you to create objects of this class in the same way you would create primitive variables.
a. Random
b. String
c. PrintWriter
d. Scanner
ANS: B
ANS: D
10. Data hiding, which means that critical data stored inside the object is protected from code outside the object, is
accomplished in Java by:
a. using the public access specifier on the class methods
b. using the private access specifier on the class methods
c. using the private access specifier on the class definition
d. using the private access specifier on the class fields
ANS: D
ANS: D
12. You should not define a class field that is dependent upon the values of other class fields:
a. in order to avoid having stale data
b. because it is redundant
c. because it should be defined in another class
d. in order to keep it current
ANS: A
ANS: D
ANS: B
ANS: A
16. A constructor:
a. always accepts two arguments
b. has return type of void
c. has the same name as the class
d. always has an access specifier of private
ANS: C
17. Which of the following statements will create a reference, str, to the String, “Hello, World”?
a. String str = "Hello, World";
b. string str = "Hello, World";
c. String str = new "Hello, World";
d. str = "Hello, World";
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education
ANS: A
18. Two or more methods in a class may have the same name as long as:
a. they have different return types
b. they have different parameter lists
c. they have different return types, but the same parameter list
d. you cannot have two methods with the same name
ANS: B
19. Given the following code, what will be the value of finalAmount when it is displayed?
ANS: D
20. A class specifies the ________ and ________ that a particular type of object has.
a. relationships; methods
b. fields; object names
c. fields; methods
d. relationships; object names
ANS: C
21. This refers to the combining of data and code into a single object.
a. Data hiding
b. Abstraction
c. Object
d. Encapsulation
ANS: D
ANS: B
23. In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top
section has the _______; the middle section holds _______; the bottom section holds _______.
a. class name; attributes or fields; methods
b. class name; object name; methods
c. object name; attributes or fields; methods
d. object name; methods; attributes or fields
ANS: A
ANS: D
a. methods private
b. fields private
c. fields public
d. fields and methods public
ANS: B
26. After the header, the body of the method appears inside a set of:
a. brackets, []
b. parentheses, ()
c. braces, {}
d. double quotes, ""
ANS: C
ANS: C
a. /
b. @
c. -
d. +
ANS: D
ANS: B
30. When an object is created, the attributes associated with the object are called:
a. instance fields
b. instance methods
c. fixed attributes
d. class instances
ANS: A
31. When an object is passed as an argument to a method, what is passed into the method’s parameter variable?
a. the class name
b. the object’s memory address
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education
ANS: B
ANS: D
ANS: D
34. Which of the following statements will create a reference, str, to the string, “Hello, world”?
a. 1
b. 2
c. 1 and 2
d. Neither 1 or 2
ANS: C
ANS: C
36. Given the following code, what will be the value of finalAmount when it is displayed?
orderNum = orderNumber;
orderAmount = orderAmt;
orderDiscount = orderDisc;
}
ANS: C
ANS: C
38. Instance methods do not have this key word in their headers:
a. public
b. static
c. private
d. protected
ANS: B
39. Which of the following is not involved in finding the classes when developing an object-oriented application?
ANS: C
a. archive c. collection
b. package d. attachment
ANS: B
41. Quite often you have to use this statement to make a group of classes available to a program.
a. import c. link
b. use d. assume
ANS: A
import java.util.Scanner;
This is an example of
ANS: B
import java.util.*;
ANS: A
44. The following package is automatically imported into all Java programs.
a. java.java c. java.util
b. java.default d. java.lang
ANS: D
TRUE/FALSE
ANS: T
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education
ANS: T
ANS: T
4. A method that stores a value in a class's field or in some other way changes the value of a field is known as a
mutator method.
ANS: T
ANS: F
ANS: T
7. Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter
variable.
ANS: T
8. The public access specifier for a field indicates that the attribute may not be accessed by statements outside
the class.
ANS: F
9. A method that gets a value from a class's field but does not change it is known as a mutator method.
ANS: F
10. Instance methods do not have the key word static in their headers.
ANS: T
11. The term "default constructor" is applied to the first constructor written by the author of a class.
ANS: F
12. When a local variable in an instance method has the same name as an instance field, the instance field hides the
local variable.
ANS: F
13. The term "no-arg constructor" is applied to any constructor that does not accept arguments.
ANS: T
14. The java.lang package is automatically imported into all Java programs.
ANS: T
Visit https://testbankbell.com
now to explore a rich
collection of testbank,
solution manual and enjoy
exciting offers!
Other documents randomly have
different content
thunderstorm. The sparks of home-made lightning will jump several
inches.
Do not think that electricity is generated in a commercial way by
static electric machines. The practical uses of static electricity are
very few when compared with those of current electricity from
batteries and dynamos.
15. Condensation of Static Electricity. By means of
apparatus called condensers, a terrific charge of static electricity may
be stored. Fig. 11 shows the most common form of condenser,
known as the Leyden jar. It consists of a glass jar with an inside and
outside coating of tin-foil.
Fig. 12.
Fig. 11.
To charge the jar it is held in the hand so that the outside coating
shall be connected with the earth, the sparks from an electric
machine being passed to the knob at the top, which is connected by
a chain to the inside coating.
To discharge the jar, Fig. 12, a conductor with an insulating
handle is placed against the outside coat; when the other end of the
conductor is swung over towards the knob, a bright spark passes
between them. This device is called a discharger. Fig. 13 shows a
discharge through ether which the spark ignites.
Fig. 13.
Fig. 14.
17. Electromotive Force of
Static Electricity. Although the
sparks of static electricity are large,
the quantity of electricity is very
small. It would take thousands of
galvanic cells to produce a spark an
inch long. While the quantity of
static electricity is small, its
potential, or electromotive force (E.
M. F.), is very high. We say that an
ordinary gravity cell has an E. M. F.
of a little over one volt. Five such
cells joined in the proper way would
have an E. M. F. of a little over five
volts. You will understand, then, Fig. 15.
what is meant when we say that the
E. M. F. of a lightning flash is millions
of volts.
18. Atmospheric Electricity. The air is usually electrified, even
in clear weather, although its cause is not thoroughly understood. In
1752 it was proved by Benjamin Franklin (Fig. 15), with his famous
kite experiment, that atmospheric and frictional electricities are of
the same nature. By means of a kite, the string being wet by the
rain, he succeeded, during a thunderstorm, in drawing sparks,
charging condensers, etc.
19. Lightning may be produced by
the passage of electricity between
clouds, or between a cloud and the
earth (Fig. 16), which, with the
intervening air, have the effect of a
condenser. When the attraction
between the two electrifications gets
great enough, a spark passes. When
the spark has a zigzag motion it is
Fig. 16. called chain lightning. In hot weather
flashes are often seen which light
whole clouds, no thunder being heard. This is called heat lightning,
and is generally considered to be due to distant discharges, the light
of which is reflected by the clouds. The lightning flash represents
billions of volts.
Fig. 17.
20. Thunder is caused by the violent disturbances produced in
the air by lightning. Clouds, hills, etc., produce echoes, which, with
the original sound, make the rolling effect.
21. Lightning-Rods, when well constructed, often prevent
violent discharges. Their pointed prongs at the top allow the
negative electricity of the earth to pass quietly into the air to
neutralize the positive in the cloud above. In case of a discharge, or
stroke of lightning, the rods aid in conducting the electricity to the
earth. The ends of the rods are placed deep in the earth, Fig. 17.
22. St. Elmo's Fire. Electrification from the earth is often drawn
up from the earth through the masts of ships, Fig. 18, to neutralize
that in the clouds, and, as it escapes from the points of the masts,
light is produced.
Fig. 18.
Fig. 21.
Fig. 23.
Fig. 25.
Fig. 26.
Fig. 27.
Fig. 28.
37. Magnetic Field. If a bar magnet be laid upon the table, and
a compass be moved about it, the compass-needle will be attracted
by the magnet, and it will point in a different direction for every
position given to the compass. This strange power, called
magnetism, reaches out on all sides of a magnet. The magnet may
be said to act by induction upon the compass-needle. The space
around the magnet, in which this inductive action takes place, is
called the magnetic field. Fig. 28 shows some of the positions taken
by a compass-needle when moved about on one side of a bar
magnet.
Fig. 29. Fig. 30.
Fig. 33.
Fig. 32.
44. Early
Experiments. In 1786
Galvani, an Italian
physician, made
experiments to study
the effect of static
electricity upon the
nervous excitability of
animals, and especially
upon the frog. He found
that electric machines
were not necessary to
produce muscular
contractions or kicks of
the frog's legs, and that
they could be produced
when two different
metals, Fig. 35, like iron
and copper, for example, Fig. 35.
were placed in proper
contact with a nerve and
a muscle and then made to touch each other. Galvani first thought
that the frog generated the electricity instead of the metals.
Volta proved that the electricity was caused by the contact of the
metals. He used the condensing electroscope as one means of
proving that two dissimilar metals become charged differently when
in contact. Volta also carried out his belief by constructing what is
called a Voltaic Pile. He thought that by making several pairs of
metals so arranged that all the little currents would help each other,
a strong current could be generated. Fig. 36 shows a pile, it being
made by placing a pair of zinc and copper discs in contact with one
another, then laying on the copper disc a piece of flannel soaked in
brine, then on top of this another pair, etc., etc. By connecting the
first zinc and the last copper, quite a little current was produced.
This was a start from which has been built our present knowledge of
electricity. Strictly speaking, electricity is not generated by
combinations of metals or by cells; they really keep up a difference
of potential, as will be seen.
Fig. 36.
Fig. 37.
Fig. 38.
45. The Simple Cell. It has been stated that two different kinds
of electrifications may be produced by friction; one positive, the
other negative. Either can be produced, at will, by using proper
materials. Fig. 37 shows a section of a simple cell; Fig. 38 shows
another view. Cu is a piece of copper, and Zn a piece of zinc. When
they are placed in dilute sulphuric acid, it can be shown by delicate
apparatus that they become charged differently, because the acid
acts differently upon the plates. They become charged by chemical
action, and not by friction. The zinc is gradually dissolved, and it is
this chemical burning of the zinc that furnishes energy for the
electric current in the simple cell. The electrification, or charge, on
the plates tends to flow from the place of higher to the place of
lower potential, just as water tends to flow down hill. If a wire be
joined to the two metals, a constant current of electricity will flow
through it, because the acid continues to act upon the plates. The
simple cell is a single-fluid cell, as but one liquid is used in its
construction.
45a. Plates and Poles. The metal strips used in voltaic cells are
called plates or elements. The one most acted upon by the acid is
called the positive (+) plate. In the simple cell the zinc is the +
plate, and the copper the negative (-) plate. The end of a wire
attached to the - plate is called the + pole, or electrode. Fig. 37
shows the negative (-) electrode as the end of the wire attached to
the + plate.
46. Direction of Current. In the cell the current passes from
the zinc to the copper; that is, from the positive to the negative
plate, where bubbles of hydrogen gas are deposited. In the wire
connecting the plates, the current passes from the copper to the zinc
plate. In most cells, carbon takes the place of copper. (See "Study,"
§ 268.)
47. Local Currents; Amalgamation. Ordinary zinc contains
impurities such as carbon, iron, etc., and when the acid comes in
contact with these, they form with the zinc a small cell. This tends to
eat away the zinc without producing useful currents. The little
currents in the cell from this cause are called local currents. (See
"Study," Exp. 111, § 273.) This is largely overcome by coating the
zinc with mercury. This process is called amalgamation. It makes the
zinc act like pure zinc, which is not acted upon by dilute sulphuric
acid when the current does not pass. (See "Study," § 257, 274.)
48. Polarization of Cells. Bubbles of hydrogen gas are formed
when zinc is dissolved by an acid. In the ordinary simple cell these
bubbles collect on the copper plate, and not on the zinc plate, as
might be expected. The hydrogen is not a conductor of electricity, so
this film of gas holds the current back. The hydrogen acts like a
metal and sets up a current that opposes the zinc to the copper
current. Several methods are employed to get rid of the hydrogen.
(See "Study," § 278, 279, 280.)
CHAPTER IV.
VARIOUS VOLTAIC CELLS.
testbankfan.com