Starting Out with Java Early Objects 6th Edition Gaddis Test Bankinstant download
Starting Out with Java Early Objects 6th Edition Gaddis Test Bankinstant download
https://testbankfan.com/product/starting-out-with-java-early-
objects-6th-edition-gaddis-test-bank/
We believe these products will be a great fit for you. Click
the link to download now, or visit testbankfan.com
to discover even more!
https://testbankfan.com/product/starting-out-with-java-early-
objects-6th-edition-gaddis-solutions-manual/
https://testbankfan.com/product/starting-out-with-c-early-
objects-9th-edition-gaddis-test-bank/
https://testbankfan.com/product/starting-out-with-c-early-
objects-7th-edition-gaddis-solutions-manual/
https://testbankfan.com/product/international-financial-
management-7th-edition-eun-solutions-manual/
Organizational Behavior A Critical Thinking Approach
1st Edition Neck Solutions Manual
https://testbankfan.com/product/organizational-behavior-a-
critical-thinking-approach-1st-edition-neck-solutions-manual/
https://testbankfan.com/product/quantitative-analysis-for-
management-13th-edition-render-test-bank/
https://testbankfan.com/product/physical-chemistry-2nd-edition-
ball-solutions-manual/
https://testbankfan.com/product/business-math-using-excel-2nd-
edition-burton-solutions-manual/
https://testbankfan.com/product/assessing-learners-with-special-
needs-an-applied-approach-7th-edition-overton-test-bank/
Microsoft Visual Basic 2017 for Windows Web and
Database Applications Comprehensive 1st Edition
Hoisington Solutions Manual
https://testbankfan.com/product/microsoft-visual-basic-2017-for-
windows-web-and-database-applications-comprehensive-1st-edition-
hoisington-solutions-manual/
Starting Out with Java Early Objects 6e (Gaddis)
Chapter 7 Arrays and the ArrayList Class
TRUE/FALSE
1. An ArrayList object automatically expands in size to accommodate the items stored in it.
ANS: T
2. Java does not limit the number of dimensions an array may have.
ANS: T
3. The String[] args parameter in the main method header allows the program to receive
arguments from the operating system command-line.
ANS: T
4. When an array of objects is declared but not initialized, the array values are set to 0.
ANS: F
5. To determine if two arrays are equal you must compare each of the elements of the two arrays.
ANS: T
6. A sorting algorithm is a technique for scanning through an array and rearranging its contents in some
specific order.
ANS: T
7. Objects in an array are accessed with subscripts, just like any other data type in an array.
ANS: T
8. Any items typed on the command-line, separated by space, after the name of the class, are considered
to be one or more arguments that are to be passed into the main method.
ANS: T
ANS: F
10. The Java compiler will display an error message when it processes a statement that uses an invalid
subscript.
ANS: F
MULTIPLE CHOICE
1. A search algorithm
a. arranges elements in ascending order
b. arranges elements in descending order
c. is used to locate a specific item in a collection of data
d. is rarely used with arrays
ANS: C
2. A ragged array is
a. a two-dimensional array where the rows have different numbers of columns
b. a one-dimensional array for which the number of elements is unknown
c. a two-dimensional array for which the number of rows is unknown
d. a partially initialized two-dimensional array of ranged values
ANS: A
5. Java provides a mechanism known as a __________ which makes it possible to write a method that
takes a variable number of arguments.
a. variable-length argument list
b. dynamic parameter list
c. unary-signature template
d. polymorphic byte code
ANS: A
11. You can use the __________ method to replace an item at a specific location in an ArrayList.
a. set
b. remove
c. replace
d. add
ANS: A
12. Which of the following is a correct method header for receiving a two-dimensional array as an
argument?
a. public static void passMyArray(int[]myArray1, int[]myArray2)
b. public static void passMyArray(int[][] myArray)
c. public static void passMyArray[][](int myArray)
d. public static void passMyArray(array myArray)
ANS: B
13. Which of the following import statements is required in order to use the ArrayList class?
a. import java.util.Tools;
b. import java.util.ArrayList;
c. import java.util.Containers;
d. import java.util.API;
ANS: B
14. Which method is used to determine the number of items stored in an ArrayList object?
a. items
b. listLength
c. size
d. volume
ANS: C
15. The __________ method removes an item from an ArrayList at a specific index.
a. remove
b. pop
c. deleteAt
d. clear
ANS: A
16. Which of the following methods returns a string representing all of the items stored in an ArrayList
object?
a. show
b. toString
c. print
d. getList
ANS: B
17. Which of the following ArrayList class methods is used to insert an item at a specific location in an
ArrayList?
a. set
b. store
c. add
d. insert
ANS: C
18. To return an array of long values from a method, which return type should be used for the method?
a. long[ARRAY_SIZE]
b. array
c. long[]
d. long
ANS: C
19. Which of the following is a valid declaration for a ragged array with five rows but no columns?
a. int[][] ragged = new int[5];
b. int[][] ragged = new int[][5];
c. int[][] ragged = new int[5][];
d. int[] ragged = new int[5];
ANS: C
20. If numbers is a two-dimensional array, which of the following would give the number of columns in
row r?
a. numbers.length
b. numbers.length[r]
c. numbers[r].length
d. numbers[r].length[r]
ANS: C
22. Given the following two-dimensional array declaration, which statement is true?
int[][] numbers = new int[6][9];
a. The numbers array has 54 rows.
b. The numbers array has 15 rows.
c. The numbers array has 6 rows and 9 columns.
d. The numbers array has 6 columns and 9 rows.
ANS: C
23. What will be the result after the following code is executed?
final int ARRAY_SIZE = 5;
float[] x = float[ARRAY_SIZE];
for (i = 1; i <= ARRAY_SIZE; i++)
{
x[i] = 10.0;
}
a. A runtime error will occur.
b. All the values in the array will be initialized to 10.0.
c. All the values in the array except the first will be set to 10.0.
d. The code contains a syntax error and will not compile.
ANS: D
24. For the following code, what would be the value of str[2]?
String[] str = {"abc", "def", "ghi", "jkl"};
a. a reference to the String object containing "ghi"
b. "ghi"
c. a reference to the String object containing "def"
d. "def"
ANS: A
25. What would be the result after the following code is executed?
int[] numbers = {40, 3, 5, 7, 8, 12, 10};
int value = numbers[0];
for (int i = 1; i < numbers.length; i++)
{
if (numbers[i] < value)
value = numbers[i];
}
a. The value variable will contain the average of all the values in the numbers array.
b. The value variable will contain the sum of all the values in the numbers array.
c. The value variable will contain the lowest value in the numbers array.
d. The value variable will contain the highest value in the numbers array.
ANS: C
26. What would be the result after the following code is executed?
int[] numbers = {50, 10, 15, 20, 25, 100, 30};
int value = 0;
for (int i = 1; i < numbers.length; i++)
value += numbers[i];
a. The value variable will contain the average of all the values in the numbers array.
b. The value variable will contain the sum of all the values in the numbers array.
c. The value variable will contain the lowest value in the numbers array.
d. The value variable will contain the highest value in the numbers array.
ANS: B
29. Which of the following statements is(are) true about this code?
final int ARRAY_SIZE = 10;
long[] array1 = new long[ARRAY_SIZE];
a. It declares array1 to be a reference to an array of long values.
b. It will allow valid subscripts in the range of 0 through 9.
c. It creates an instance of an array of ten long values.
d. All of these are true.
ANS: D
Rub-a-dub-dub!
Rub-a-dub-dub!
Hurrah for the girls of the Blue Ribbon Club!
And whether we’re beating,
Or heating,
Or eating,
We always have fun at the Blue Ribbon Club!
“Dear! I’m sure we’ve forgotten the most important things. Lard.”
“Rice.”
“We ought to have some canned things.”
“Well, let him bring what we’ve ordered, and then we can
remember what we’ve forgotten. Soap.”
“Ammonia.”
“Salad-oil.”
“Now one thing suggests another! Lemons.”
“Cheese.”
“Macaroni.”
“Macaroons.”
“He doesn’t keep those; the baker does. Don’t let’s order any
more things now; I’m all mixed up.”
Mr. Fenn went away well pleased with his order, and Millicent
dropped into a kitchen chair exhausted.
“Girls,” said Hester, “you’ve run up an awful big order; do you
suppose it will cost all our money?”
“Oh, no,” said the wise and matronly Marguerite, shaking her
halo; “and, besides, most of those things won’t need to be ordered
again; the staples will last us all the time we’re here. Now when they
bring the bills I’ll fix up my accounts. I have a little red book, real
Russia, and I’ll have a page for each department. Are these
committees standing ones, Miss President?”
“Oh, no!” said Marjorie, “we’ll take turns at things. I don’t want
to order groceries again. I’m quite worn out.”
“Poor Margy! ‘Come rest in this bosom, my own stricken deer,’ ”
sang Nan, catching Marjorie about the waist and dancing round the
kitchen with her.
“Oh, I am so hungry!” pleaded Betty. “Can’t we get out the silver
and table-cloth and set the table now?”
“Yes, come on; I love to set a table,” said Nan. “But oh, how I
hate to wash dishes! I thought we were going to have an Irish lady
to do that, eh, Marjorie?”
“Aunt Molly says there’s a nice Irish girl who lives up the beach
somewhere who would come and help us for a consideration. You
and Marguerite go and hunt her up. Her name is Rosie O’Neill.”
“Beautiful name!” said Nan.
“A lady named Rosie O’Neill
I’m sure will be loyal and leal;
Fulfilling our wishes,
She’ll wash up our dishes,
And our apples and onions she’ll peel.
A
GAIN Marjorie rapped on the table with her iron spoon.
“As none of you seems to offer any suggestions,” she went
on, as if she had not been interrupted at all, “I will lay down
the law. Hester, you’re Stoker. The coal and wood has come. Now
see if you can make a fire that shall be worthy of one whom England
expects this day to do her duty!”
“Aye, aye!” said Hester, bringing her hand to her temple, palm
forward, with the quick, jerky salute of a British marine.
“Helen, you and Jessie might set the table; but don’t both of you
get to singing at once, for you’ll drive us distracted. Millicent, what
are you good for, anyway?”
Millicent was putting away the groceries that were piled on the
table in the outer kitchen, or buttery, as Hester called it, and she
replied: “Oh, I would ornament any calling; but when I see these
candles and kerosene it makes me just long to fill the lamps and
candlesticks, ’cause it’s going to get dark pretty soon.”
“You’re a wise virgin,” said Betty, “and you shall be our honored
Lamplighter. I suppose I must peel these potatoes. How many,
Duchess?”
“Two apiece,” replied Marjorie. “We’ll have them mashed, and the
onions fried, and the steak broiled, and I’ll make coffee, and that’s
all we’ll have cooked for supper. You can hunt up some dessert out
of the things that came from the grocer’s.”
Many hands make light work, and in half an hour everything was
about ready. The table was laid, and wonderfully pretty it looked,
too; for under Jessie’s supervision it had blossomed out into dainty
doilies, and bits of shining glass and silver; and in the center was a
low basket of goldenrod.
Not finding a satisfactory dessert in the cupboard, Helen had run
over to the grocer’s herself, and returned triumphantly with a box of
candied ginger, an Edam cheese, and a tin box of biscuits. These
and the coffee-cups she arranged on a side-table, and surveyed the
result with a very pardonable pride.
Millicent had filled and lighted the large swinging-lamp over the
table, and candles twinkled from a pair of old-fashioned candelabra
which Jessie had discovered in the attic. In the kitchen, too, all was
in readiness.
Betty had boiled and mashed the potatoes until Millicent declared
they looked like cotton batting. Marjorie had broiled the steak to the
proverbial turn, fried the onions to an odoriferous brown, and made
a potful of her celebrated coffee; and now, flushed with success and
Hester’s fire, she sat on the edge of the kitchen table, her iron spoon
still in her hand, like a scepter.
“Whe-e-w!” said Helen, coming out. “You must be cooking
comparisons out here, they’re so odorous.”
“In onion is strength,” replied Betty.
“Why don’t you take something for that punning habit, Betty?
Really, it’s getting worse, I think. Oh, I wish Nan and the Matron
would come! I am so starved.”
And in a few minutes they did come—tired and chilled with their
long walk, and without the much-desired Irish lady.
“Where’s your captive?”
“Couldn’t you catch her?”
“Is she coming?”
“Yes,” said Marguerite, “it’s all right. Don’t all talk at once; let me
tell you. She can’t come until to-morrow, but she’ll be here early—
before breakfast.”
“Then we’ve got to wash the dishes to-night, haven’t we?”
groaned Jessie.
“Never mind, my pretty Scullery-maid,” said Betty; “you needn’t
do it: you can put them away with neatness and despatch.” And
Jessie beamed again.
“Can you guess what we’re going to have for supper?” said
Marjorie.
“Guess!” said Nan. “I should think we could! Why, we met the
announcement three blocks up the street, and it led us all the way
home, like the Israelites’ pillar of fire. Is supper ready?”
“Yes,” chimed a chorus; and in less time than it takes to tell it the
feast was on the table.
“You sit at the head, Duchess,” said Betty, “and I’ll sit at the foot
and carve, for none of the rest of you know how. The fair Scullery-
maid can sit at my right hand in case I need her assistance, Nan and
Daisy next, then Millicent at Marjorie’s right, and then Helen and
Hester; and there you are!”
There they were indeed, and a merrier meal was never eaten by
the Blue Ribbon Cooking Club.
The prosaic onions were pronounced better than any complicated
French concoction, and were portioned out with exact fairness by
the conscientious Betty.
Nan and Marguerite, having done nothing toward the
preparations, offered their services as waitresses, and, like well-
trained club members, they removed one course and served the
other in the most approved fashion.
Then Marjorie poured coffee, and the red-coated cheese was
placed before Betty, who thoroughly enjoyed “scooping,” and there
was much laughter and merry talk. And they all complimented each
other and congratulated each other, and they feasted and jested,
and laughed and chaffed; and as they all talked at once, each made
jokes that never were heard, and told stories that never were
listened to, and asked questions that never were answered. And
Timmy Loo thought it was all a great entertainment for his special
benefit; and he barked his funniest barks, and ran round the table
like mad, and paused in front of each one, standing up and putting
out his paw in his very best beggarly manner, receiving always a bit
of ginger or biscuit on his solicitous little nose. Until finally Marjorie
said. “Now, sisters, if there’s any redding up to be done, ’twere well
’twere done quickly. I don’t mind washing the dishes, and if we all fly
round we’ll have things in order in no time.”
They did fly round, and in very little more than no time things
were in order, and the eight girls, feeling very proud of their tidy
kitchen, gathered round Hester’s wood fire in the Grotto, as Millicent
persisted in calling the parlor.
And then Uncle Ned and Aunt Molly came over to call, and were
nearly talked to death by the enthusiastic eight, who were delighted
to have some one to “tell things to.”
The much-amused guests were escorted out to the kitchen to
see how beautifully the young housekeepers had “redded up,” and
then they were invited to partake of crackers and cheese in the
dining-room; and such a hospitable spirit pervaded the hostesses
that they refreshed themselves also, until the crackers were all gone
and the cheese required deep-sea scooping.
“Well, you certainly seem a capable crowd,” said Aunt Molly, as
she was taking leave. “Are you sure you won’t be afraid to-night?”
“Of course they won’t,” said Uncle Ned, in tones that would have
inspired confidence in a lame rabbit. “What is there to be afraid of?
Long Beach is the safest old place in the world. But, my lambs, if
you want us at any hour of the day or night, you’ve only to push this
bell in the hall, which communicates with our bell, and we’ll fly over.”
“Now,” said Matron Marguerite, as they returned to the Grotto, “I
am going to make up my accounts. I have all the bills that came in
to-day, and I have five dollars apiece from each one of you for the
first week, though I’m afraid it won’t be enough, and Helen forgot to
give me hers anyway, and Betty gave hers to me and then borrowed
it back again; and I haven’t paid my own yet either, but I paid out
eighty cents for our stage-fares, and twenty-five cents expressage,—
no, fifty,—and fourteen cents for two quarts of milk. You see, I didn’t
know we were going to have bills, and I almost wish we hadn’t. Oh,
yes, and I owe Marjorie thirty-six cents that she paid to the butter-
and-egg lady—I mean the club owes it. But I guess I can straighten
it all out.”
“You ought to have one of those cash-register things,” said
Millicent. “You just play on it with your fingers, and it rings a bell and
counts your money for you.”
“I wish I had one,” said Marguerite, who was beginning to be
arithmetically bewildered. “But I’ll be all right if you girls will let me
alone.”
“We will, we will,” said Nan. “Just remember, Daisy, that two and
two make four, and then go ahead. Now I’m going to begin our
Journal. I brought a grand and elegant new blank-book for the
purpose. We must write something in it every day, and we’ll keep it
here on the table where anyone can write a page when she feels
disposed. What shall we call it? What’s the name of this cottage,
Marjorie?”
“Oh, father calls it Fair View, but I don’t think that’s much of a
name. Let’s christen it for ourselves.”
“Call it Liberty Hall,” said Jessie, “because we’re going to do just
as we like all the time we’re here.”
“Too hackneyed,” returned Betty. “Let’s call it Hilarity Hall,
because we’re going to have lots of fun here.”
So Hilarity Hall it was, and Nan printed it in big letters on the fly-
leaf of her book. Then she began to scribble, and the others leaned
over her shoulder and knelt at her side, and helped and suggested
and amended, until the first instalment of the Journal stood thus,
and Nan read it aloud, amid a fire of running comment:
T
HE sun was shining o’er the sea, shining with all its might, and
had been doing so for two hours, but no one in Hilarity Hall had
awakened to the fact. A loud rap at the kitchen door partially
roused sleepy Jessie, who murmured, “Yes, mamma,” and dozed off
again. But Betty was thoroughly awakened by the sound, and, giving
Jessie a shake, she exclaimed: “I believe it’s that horde of men
again!” Then, springing up, she began to dress hastily.
The knocking not only continued but was supplemented by other
peremptory sounds,—a ring at the front-door bell, a toot on a tin
fish-horn, the postman’s whistle,—all of which were responded to by
frantic barkings from Timmy Loo, who tore madly from one door to
another, bouncing at last into Betty’s room and waltzing before her
on his hind legs. His fat little body was quivering with excitement,
and his bright eyes blinked through the wispy locks that hung over
them.
But Betty was struggling with a stiff shirt-waist and a pair of
sleeve-links, and her fruitless endeavors to bring them into harmony
rendered her incapable of good work in that direction. Then Timmy
Loo grew wheedlesome and patted Betty’s foot, as was his custom
when he wanted anybody to go anywhere. Betty pushed him aside,
a little impatiently it seemed to Tim, and he ran to Jessie, who was
enjoying the added luxury of Betty’s pillow, and looking as if she
would stay there undisturbed though China fell.
But the second-story contingent was also aroused by this time,
and six frowzled heads hung over the banister and twelve bare feet
poked themselves between the rails.
“Can’t you go, Betty?” said Marguerite’s plaintive voice.
“I’ll be down in a minute,” sang out Marjorie, as she skipped back
to her room and made things fly.
“Oh, hang!” said Betty, throwing her links down on the bureau
and flinging her shirt-waist across the room.
“Take mine, dear,” said Jessie, placidly; “it’s on that chair, and the
buttons are all in it.”
Betty’s face cleared, and she slipped on Jessie’s waist in a jiffy,
and was at the front door in another.
There she found the postman and a pleasant-faced Irish girl who
said:
“I’m Rosie, mum.”
“You are indeed,” said Betty, looking at her red cheeks; “come
in.”
Just then Hester landed in the lower hall with a jump which had
included the last four stairs.
“I’m glad to see you, Rosie,” said she, kindly; “come along with
us and we’ll face the bombardment.”
Rosie, looking somewhat bewildered, followed the two girls to
the kitchen. Going through, Betty unlocked the door which opened
into a sort of outer kitchen or shed with latticed and morning-gloried
walls. The door of the shed too was barred, and when this was
finally unfastened, instead of the looked-for multitude they saw only
the red-haired grocer sitting dejectedly on the stump of a tree.
He took off his cap as he saw the girls, and his hair blazed
merrily in the sunshine.
“Morning, young ladies,” said he; “the fish-man he couldn’t wait
no longer, and the vegetable-man likewise was in a hurry. But I sez,
I’ll wait, fer like as not there’ll be things you fergot overnight,
besides fresh orders.”
“Yes,” said Hester, abstractedly; “but couldn’t you come round
again later? We’re—we haven’t decided yet what we do want.”
“Well, no, mum, I couldn’t call later—not to say later. I’ll be
round again to deliver the goods, but not to take orders.”
“I’ll tell you what, Hester,” said Betty; “don’t order now, and after
breakfast some of us can ride over on our wheels and leave the
order in time for him to bring the things. Er—what shall I call you,
sir?”
“Dan’l, mum.”
“Well, Daniel, we won’t give you any order now, but we’ll send it
over to the store.”
“All right, mum”; and looking a little injured, the red-haired one
shambled off.
“Now,” said Betty, “we must have breakfast first of all; and as I
cooked most of the dinner last night, it isn’t my turn this morning.
Marguerite’s the Matron of this establishment, and I think she ought
to assume some responsibility.”
“So do I,” said Betty; “let’s go and read the Riot Act to her.”
“No,” said Hester; “let’s write a mandamus or habeas corpus or
whatever they call it, and send it up to her by Rosie, and we’ll go for
a spin on our wheels.”
Whisking a leaf off the order-pad, Betty wrote in large letters:
MATRON MARGUERITE
OF
HILARITY HALL
WILL PREPARE AND SERVE
BREAKFAST
THIS (FRIDAY) MORNING
IN THE
REFECTORY
COVERS LAID FOR EIGHT
“There, Rosie; take that upstairs, please, and knock at the first
door at the head of the stairs, and give this to the young lady with
the fly-away yellow hair: the one that came to see you last night,
you know—Miss Marguerite.”
“Yes, mum,” said Rosie.
Then Hester and Betty each drank a tumblerful of the fresh milk
Farmer Hobbs had brought, and in great glee started off on their
wheels, while Timmy Loo scampered along behind.
“It seems mean to run away,” said Hester; but Betty replied:
“Not at all; it’s only fair that Daisy should do some work. Let’s go
around by the church and down that road to the beach.”
Rosie started obediently on her errand; but Jessie stopped her as
she passed the door, inquiring:
“Where did the girls go?”
“I cudden’t tell ye, miss; they wint galloping away on their
bicycles.”
“They did! What about breakfast?”
“They towld me to give this note to Miss Margreet.”
“Oho!” said Jessie, reading the notice, “they did, did they? Well,
take it up, Rosie.” And Jessie sauntered out on the piazza and sniffed
the salt morning air.
Rosie went upstairs with the note, but her knock at the door
received no response. After another gentle rap she opened the door,
to find the room vacated. The bed-clothing was thrown back and the
windows wide open.
“Faix, they’ve been shpirited away,” thought the astonished maid.
“If this ain’t the quarest family! I’ll be l’avin’ if things goes on like
this.”
Uncertain how to proceed, she returned to the kitchen, and sat
down with folded hands to await developments.
Helen came downstairs next. Seeing nobody around, she went
into the kitchen, and looked amazed at the solitary Rosie.
“Where is everybody?” began Helen.
“Sure, I don’t know, mum. Thim as was in the house wint out,
and the rest was gone before.”
“Well, of all performances!” And Helen wandered out to the front
veranda, and discovered Jessie there.