Starting Out with Java From Control Structures through Data Structures 3rd Edition Gaddis Test Bank instant download
Starting Out with Java From Control Structures through Data Structures 3rd Edition Gaddis Test Bank instant download
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/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/college-algebra-7th-edition-blitzer-
solutions-manual/
Payroll Accounting 2015 1st Edition Landin Solutions
Manual
https://testbankfan.com/product/payroll-accounting-2015-1st-edition-
landin-solutions-manual/
https://testbankfan.com/product/chemistry-6th-edition-mcmurry-test-
bank/
https://testbankfan.com/product/principles-of-animal-physiology-3rd-
edition-moyes-test-bank/
https://testbankfan.com/product/general-organic-and-biochemistry-an-
applied-approach-2nd-edition-james-armstrong-solutions-manual/
https://testbankfan.com/product/psychology-a-framework-for-everyday-
thinking-1st-edition-lilienfeld-test-bank/
Social Animal 11th Edition Aronson Test Bank
https://testbankfan.com/product/social-animal-11th-edition-aronson-
test-bank/
Starting Out with Java: From Control Structures through Data Structures 3e (Gaddis and Muganda)
Chapter 6 A First Look at Classes
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
Answer: 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
Answer: B
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
Answer: A
1
Copyright © 2016 Pearson Education, Inc.
7) Most programming languages that are in use today are:
A) procedural
B) logic
C) object-oriented
D) functional
Answer: 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
Answer: B
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
Answer: D
2
Copyright © 2016 Pearson Education, Inc.
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
Answer: 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
Answer: 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";
Answer: A
3
Copyright © 2016 Pearson Education, Inc.
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
Answer: B
19) Given the following code, what will be the value of finalAmount when it is displayed?
4
Copyright © 2016 Pearson Education, Inc.
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
Answer: C
21) This refers to the combining of data and code into a single object.
A) Data hiding
B) Abstraction
C) Object
D) Encapsulation
Answer: D
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
Answer: A
5
Copyright © 2016 Pearson Education, Inc.
26) After the header, the body of the method appears inside a set of:
A) brackets, []
B) parentheses, ()
C) braces, {}
D) double quotes, ""
Answer: C
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
Answer: 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
C) the values for each field
D) the method names
Answer: B
6
Copyright © 2016 Pearson Education, Inc.
32) A constructor is a method that:
A) returns an object of the class.
B) never receives any arguments.
C) with the name ClassName.constructor.
D) performs initialization or setup operations.
Answer: D
34) Which of the following statements will create a reference, str, to the string, "Hello, world"?
7
Copyright © 2016 Pearson Education, Inc.
36) Given the following code, what will be the value of finalAmount when it is displayed?
8
Copyright © 2016 Pearson Education, Inc.
38) Instance methods do not have this key word in their headers:
A) public
B) static
C) private
D) protected
Answer: B
39) Which of the following is NOT involved in finding the classes when developing an object-oriented
application?
A) Describe the problem domain.
B) Identify all the nouns.
C) Write the code.
D) Refine the list of nouns to include only those that are relevant to the problem.
Answer: C
41) Quite often you have to use this statement to make a group of classes available to a program.
A) import
B) use
C) link
D) assume
Answer: A
import java.util.Scanner;
This is an example of
A) a wildcard import
B) an explicit import
C) unconditional import
D) conditional import
Answer: B
9
Copyright © 2016 Pearson Education, Inc.
43) Look at the following statement.
import java.util.*;
44) The following package is automatically imported into all Java programs.
A) java.java
B) java.default
C) java.util
D) java.lang
Answer: D
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.
Answer: TRUE
7) Shadowing is the term used to describe where the field name is hidden by the name of a local or
parameter variable.
Answer: TRUE
8) The public access specifier for a field indicates that the attribute may not be accessed by statements
outside the class.
Answer: FALSE
9) A method that gets a value from a class's field but does not change it is known as a mutator method.
Answer: FALSE
10
Copyright © 2016 Pearson Education, Inc.
Visit https://testbankbell.com
now to explore a rich
collection of testbank,
solution manual and enjoy
exciting offers!
10) Instance methods do not have the key word static in their headers.
Answer: TRUE
11) The term "default constructor" is applied to the first constructor written by the author of a class.
Answer: FALSE
12) When a local variable in an instance method has the same name as an instance field, the instance field
hides the local variable.
Answer: FALSE
13) The term "no-arg constructor" is applied to any constructor that does not accept arguments.
Answer: TRUE
14) The java.lang package is automatically imported into all Java programs.
Answer: TRUE
11
Copyright © 2016 Pearson Education, Inc.
Other documents randomly have
different content
make into a huge damson and apple tart that we shall eat to-
morrow.
The old gardener then takes the longest of all the ladders and props
it up against the quince tree, for the quince is the highest of all the
trees in the orchard. One of the maids climbs half-way up below the
gardener and he gathers the green and golden quinces and passes
them to her and she passes them to the kitchenmaid, who stands
ready on the ground to put them into the basket. And the Imp and
the Elf sit in their apple tree and eat apples and laugh and then
pretend that they are two wise little owls and call tuwhit tuwhoo,
tuwhit tuwhoo, till I take up a walking-stick and pretend to shoot
them, and then they throw apples at me and we have a game of
catch with the great round red-cheeked balls. Oh, it is a jolly time,
the apple-gathering, as the Imp and the Elf would tell you.
About now the fairy Godmother works her miracle for Autumn. We
look up to the moors and find them no longer dark and dull for the
green brackens have been turned a gorgeous orange by the early
frosts in the night-times. And when we look over the farm land to
the woods we find the trees no longer green, and the Elf says, "Do
you see Ogre, the Godmother has crowned Autumn now?" and sure
enough, for the leaves are turned like the brackens into a glory of
splendid colours. And then we go and picnic in the golden woods,
and sometimes when the sun is hot we could almost fancy it was
summer if it were not for the colour. We picnic under the trees and
do our best to get a sight of a squirrel, and watch the leaves blowing
down from the trees like ruddy golden rain. Once, before we went to
the woods, I asked the Imp and the Elf which leaves fall first, the
leaves on the topmost branches of the trees or the leaves on the low
boughs, The Imp said the top ones, the Elf said the low, and the Elf
was right, although I do not think that either of them really knew.
Usually the Imp is right, and when I said the low leaves fell the first,
he said, "But isn't the wind stronger up above, and don't the high
leaves get blown hardest?" Yes, one would think that the high leaves
would be the first to drop. Can you guess why they are not? Shall I
tell you? Well, you just remember in Spring how the first buds to
open were the low ones. Then you will see why they are the first to
fall. They are the oldest. When we came to the woods we found that
this was just what was happening. All the leaves at the bottom fall,
and sometimes many of the trees in the woods kept little plumes of
leaves on their topmost twigs after all the others had gone fluttering
down the wind.
I am only going to remind you of three more things that belong to
Autumn. And one of them is pretty, and one of them is exciting, and
one of them is a little sad.
The first is a garden happening. Close under the house we have a
broad bed, and for some time before the real Autumn it is full of a
very tall plant with lots and lots of narrow dark green leaves. And
after a little it is covered with buds, rather like daisy buds only
bigger. And then one day the Imp leans out of the window and gives
a sudden wriggle. "Come and hold on to my legs, Ogre, but you
must not look." And I hold on to his round fat legs and keep my eyes
the other way. And he leans farther and farther out of the window,
puffing and panting for breath, until he can reach what he wants.
And then the fat legs kick backwards, and I pull him in, and when he
is quite in he says, "The first," and there in his hand is a beautiful
flower like a purple daisy with a golden middle to it. And sure
enough it is the first Michaelmas daisy. That is the really most
autumnal of all flowers, just as the primrose is the most special
flower of Spring.
The second of the three happenings belongs to the moorland. Up on
the high moors, where there is a broad flat place with a little marshy
pond in it, the Elf and the Imp have a few very special friends. There
are the curlews, with their speckly brown bodies and long thin beaks
and whistling screams, and the grouse who make a noise like an old
clock running down in a hurry when they leap suddenly into the air.
But these are not the favourites. The birds that the Imp and the Elf
love best of all on the moorland have a beautiful crest on the tops of
their heads, and they are clothed in white and dark green that looks
like black from a little way off. They cry pe-e-e-e-wi, pe-e-e-e-e-wi,
and the Imp cries "peewit" back to them. Some people call them
plovers, and some people call them lapwings, because of the way
they fly, but we always call them the "peewits." All through the
spring and summer they are there, and it is great fun to watch
them, for they love to fly into the air and turn somersaults, and
throw themselves about as if they were in a circus, just for fun, you
know, and because it is jolly to be alive.
But in the Autumn many of the birds do strange things. Some, like
the swallows and martins, fly far away over the seas to warmer
countries for the winter. Some only come here to spend the winter
months, living in cooler countries through the summer. And the
peewits, when Autumn comes, collect in tremendous flocks. All the
friends and relations of our peewits on the moor seem to come and
join them, and then they move away all over the country from place
to place, wherever they can get food. When we go up to the moor
just at this time, we see not two or three or half-a-dozen peewits,
but crowds and crowds of them flying low, and strutting on the
ground, with their crests high up over their heads.
The last of the three happenings is the saddest. Do you remember
the haymaking and what the hay was carted away for? You
remember how the farmers stored it to feed the cows in winter. At
the end of the Autumn comes an evening when the cows are driven
home for milking, and do not go back again. The fields are left
empty all the Winter, while the red and white cows are fastened up
in the byre (a byre is a nice name for a cowshed) to eat the hay.
When that day comes the Imp and the Elf always walk home from
the fields with the cows, and pat them and say good-bye to them at
the door of the byre, and promise to come and visit them during the
Winter. And then they come home to the house, and knock sadly on
the door of my study, and come in and say, "Ogre, the cows have
been shut up for the Winter, and nurse says we are to begin our
thicker things to-morrow." And then we are all sad, for that means
Winter. And I have to tell all sorts of jolly stories of King Frost and
the Snow Queen before we are cheerful enough to go to bed.
IV
WINTER
In Winter, real Winter, we get up with our teeth chattering to tell
each other how cold it is, and we find the water frozen in the basin,
and the soap frozen to the soap-dish, and the sponge frozen hard.
That is what Winter is like indoors, and it is not very nice. But there
is a nice indoor Winter too, when the fire is burning in the study
grate with logs on it from old broken ships, making blue flames that
lick about the chimney-hole. The Imp and the Elf plant cushions on
the floor, and I sit in a big chair and read stories to them out of a
book or tell them out of my head, making them up as I go along.
That is the greatest fun, because I do not know any better than the
children what is going to happen, whether the green pigmy or the
blue will win in the battle in the water lily, or whether the little boy
with scarlet shoes will be eaten by the giant, or whether he will
make friends with him and be asked to stop to tea. We can make
the stories do just what we want, be happy if we are happy, or full
of scrapes if we are feeling naughty.
When we are in the middle of stories like this, we hear a tremendous
screaming, screaming, screaming outside, and a white cloud passes
the window with a great, shrill shriek, and we all jump up crying,
"The gulls, the gulls!"
And in the meadow and in the garden and flying in the air,
screaming and laughing with their weird voices, are hundreds of
seagulls, blown inland from the sea, bringing wild weather with
them. You know the place where we live is only a few miles from the
sea, where it runs up into the land in a broad, sandy bay that ends
in wide marshes. There are seagulls in the bay all the year round,
and we sometimes see them in the fields in Summer before the
storms reach us from the west. But in Winter when the cold and
windy weather is coming, they fly in great flocks like clouds of huge
snow-flakes, and we watch them from the window and wonder how
soon the storm will follow them. And the next day or the day after,
or sometimes the very day when they come, the air is white again,
this time with driving snow. It comes flying past the windows, to be
whirled up high by the gale and dropped again till we see the
ground speckled with white, and then white everywhere except close
round the big tree trunks. Even the branches of the trees are heaped
with snow, so they look like white boughs with black shadows
beneath them.
It snows all day and all night, and when our eyes are tired of looking
at the shining dazzling white, we come away from the window and
sit down by the fire, and talk about it, and think of children long ago,
who used to tell each other, when it was snowing, that geese were
being plucked in Heaven.
The Imp and the Elf put the matter another way. The Imp says, "It's
old King Frost freezing the rain, isn't it, Ogre?" I say "yes." And the
Elf goes on, "He does it because he wants to run about and play
without hurting the poor little plants. He knows that he is so cold
that they would die, like the children in the story book, if he danced
about on top of them, without covering them with a blanket So he
just freezes the rain into a big cosy white blanket for them and lays
It gently down."
Presently, after we have been talking and telling stories for a little,
the Imp cries out, "Ogre, Ogre, we have forgotten all about the
cocoanut," and the Elf shouts, "Oh yes, the cocoanut," and away
they fly, leaving the door open and a horrible draught in the room.
But soon they run back again, with a saw and a gimlet, and a round,
hard, hairy cocoanut. We bore a few holes with the gimlet, to let the
cocoanut milk run out. The Imp likes cocoanut milk, but the Elf hates
it, and says it is just like medicine. Then comes the difficult part. I
have to hold the cocoanut steady on the edge of a chair, and saw
away at it, all round the end, while the Imp and the Elf stand
watching, till the hard shell is cut through. Then we knock the end
off and the cocoanut is ready. Ready for what, you want to know?
Look out of the window and then you will understand. All the ground
is covered with snow, and the poor birds are finding it difficult to find
their food. The Imp and the Elf, who love all live things, and the
birds above all, could tell you a little about that, for every winter day,
as soon as breakfast is over, they collect all the scraps off
everybody's plates, and the crumbs off the bread-board, and throw a
great bowl of food out on the snowy lawn. And then there is a fine
clutter and a fuss. Starlings, and jackdaws, and sparrows, and
blackbirds, and thrushes, and sometimes rooks, and once, one
exciting day, a couple of magpies, all squabble and fight for the
food, and of course the sparrows get the best of it, because though
they are so small they are the cheekiest little birds that ever are.
When all the food is done the birds fly away, and leave the snow
covered with the marks of their feet, like very delicate tracery, or like
that piece of embroidery that the Elf is trying to do for a Christmas
present, when she is not busy with something else.
Well, well, but still you have not told us what you want to do with
the cocoanut. Wait just a minute, just half a minute, while I tell you
about the robin. Little Mr. Redbreast does not let us see much of
himself in summer, when he is off to the hedges and the hazel
woods, having as gay a time as a happy little bird knows how to
enjoy. But he is a lazy small gentleman, and as soon as the cold
weather comes, he flies back to the houses where he has a chance
of scraps. He even flies in at the pantry window and chirps at the
cook till she gives him some food.
There are some other little birds just like the robin in this and these
are the tits. In the Summer we can see them in the woods if we go
to look for them, but they do not trouble about repaying our call;
they do not come to our gardens very often. But when Winter comes
things are on quite a different footing. They are very fond of suet or
fat or the white inside of a cocoanut, and as soon as the snow
comes so do they, looking for their food. We tie the cocoanut up
with string and hang it outside the study window from a big nail,
and before it has been there very long there is a fluttering of wings
and a little blue-capped bird with a green coat, blue splashes on his
wings, and a golden waistcoat, perches on the top of it. He puts his
head first on this side and then on that, and then he nimbly hops to
the end of the cocoanut, just above the hole, bends over, and peeps
in. He flutters off into the air and perches again, this time in the
mouth of the hole; and then suddenly he plunges his head in and
has a good peck at the juicy white stuff inside. Presently another
blue tit comes flying, and then another. They perch on the top of the
cocoanut and quarrel and flap about till the first tit has finished, and
then they both try to get into the hole together and find that it is not
big enough. We all watch them and would like to clap our hands at
the performance but dare not for fear of frightening them.
At the beginning of the Winter the tits are very shy, but later on, if
the window is open, they often alight on the window-sill and have a
good look about the room when they have had their turn at the
cocoanut and are waiting till the others have done to have a second
peck.
I think all the Seasons are jolly in their own way, and perhaps it is a
good thing that they are all so different. Do you remember the
Autumn fairy story? Well the Seasons really are just like a family of
sisters, and we should find them very dull if they were all exactly the
same. After the snowstorms, when we go out together, things are
quite different, and we are quite different. The Imp and the Elf wear
red woolly caps instead of sunbonnet and straw hat. They wear
thick, fluffy coats and piles of things underneath them, and thick
furry gloves. Why, the Elf carries a muff just like any grown-up. And
the ground has changed as much as they. It is all white with snow,
so that it is difficult to believe that the hayfield where we played in
Summer is really the same place. We put on our thickest boots, and
they go crunch, crunch in the crisp snow. And we gather the snow in
our hands and make snowballs and throw them at each other. And
then we make a giant snowball, The Imp makes the biggest
snowball he can in his hands and then puts it on the ground and
rolls it about. Everywhere it rolls the snow clings to it, and it gets
bigger and bigger till at last it is nearly as big as the Imp himself and
it takes all three of us to roll it. We roll another and put it on the top
of the first, and then a smaller one and put it on the top of that, and
then we roll snow into long lumps for arms, and there we have our
snow-man. We make eyes for him with little blobs of earth, and a
nose and a mouth, and in his mouth we always put one of my pipes
to make the poor fellow comfortable.
When we are tired of making snowballs and snow-men we go out of
the garden and across the road and along the field paths to the
wood, tramping through the shining snow. And we drag something
behind us: can you guess what it is? Do you remember in the fairy
stories about the people who lived near the forests? When the
winter came they used to shiver and rub their cold hands and go to
the forests for firewood. And as there were wolves in the forest they
used to take a sledge so that they could carry the sticks quickly back
again before the wolves could catch them. Well, when we go to the
woods in winter we pretend that we are going to the forests for
firewood and we drag the Imp's big wooden sledge behind us, and
keep a bright look-out for wolves, though, of course, there are no
wolves in England now. All the same it is very good fun to pretend
that there are.
A jolly time we have on the way to the woods. The hedges are all
bright with hips and haws, coral colour and scarlet, the fruits of the
wild rose and the hawthorn. They glitter like crimson jewels in the
white hedges, where the birds are eating them as fast as they can.
The sunlight shimmers on the snow of the fields and the snow of the
woods, and the broad white shining slopes of the distant hills. And,
of course, all the way we watch carefully for the tracks of the
wolves. We do not find them, but we find the tracks of birds that
have gone hop, hop, hop, leaving each time the print of their feet in
the snow, and the little paddy tracks of the rabbits, and the flap
tracks made by the rooks' wings as they flag up from the ground.
For a long time the road is all up hill, but then we come to a deep
slope down, when the Elf and the Imp sit on the sledge, and I give
them a push off, and away they slide, quicker and quicker all the
way to the bottom; and then, instead of going straight on to the
wood, they drag the sledge up and go down again, and then once
more, and then we all go down together and sometimes end in a
heap on the snow.
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.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
testbankfan.com