Building Java Programs A Back to Basics Approach 4th Edition Reges Test Bankdownload
Building Java Programs A Back to Basics Approach 4th Edition Reges Test Bankdownload
https://testbankfan.com/product/building-java-programs-a-back-to-
basics-approach-4th-edition-reges-test-bank/
https://testbankfan.com/product/building-java-programs-a-back-to-
basics-approach-4th-edition-reges-solutions-manual/
https://testbankfan.com/product/building-java-programs-3rd-edition-
reges-test-bank/
https://testbankfan.com/product/medical-terminology-a-word-building-
approach-7th-edition-rice-test-bank/
https://testbankfan.com/product/life-span-development-14th-edition-
santrock-test-bank/
Marketing Of High Technology Products And Innovations 3rd
Edition Mohr Test Bank
https://testbankfan.com/product/marketing-of-high-technology-products-
and-innovations-3rd-edition-mohr-test-bank/
https://testbankfan.com/product/organizational-communication-
balancing-creativity-and-constraint-7th-edition-eisenberg-solutions-
manual/
https://testbankfan.com/product/conceptual-physics-12th-edition-
hewitt-solutions-manual/
https://testbankfan.com/product/international-economics-12th-edition-
salvatore-test-bank/
https://testbankfan.com/product/educational-psychology-developing-
learners-9th-edition-ormrod-test-bank/
Mathematics for the Trades A Guided Approach 10th Edition
Carman Test Bank
https://testbankfan.com/product/mathematics-for-the-trades-a-guided-
approach-10th-edition-carman-test-bank/
Sample Final Exam #6
(Summer 2008; thanks to Hélène Martin)
1. Array Mystery
Consider the following method:
public static void arrayMystery(String[] a) {
for (int i = 0; i < a.length; i++) {
a[i] = a[i] + a[a.length - 1 - i];
}
}
Indicate in the right-hand column what values would be stored in the array after the method arrayMystery executes
if the array in the left-hand column is passed as a parameter to it.
Original Contents of Array Final Contents of Array
String[] a1 = {"a", "b", "c"};
arrayMystery(a1); _____________________________
1 of 9
2. Reference Semantics Mystery
The following program produces 4 lines of output. Write the output below, as it would appear on the console.
public class Pokemon {
int level;
battle(squirtle, hp);
System.out.println("Level " + squirtle.level + ", " + hp + " hp");
hp = hp + squirtle.level;
battle(squirtle, hp + 1);
System.out.println("Level " + squirtle.level + ", " + hp + " hp");
}
2 of 9
3. Inheritance Mystery
Assume that the following classes have been defined:
3 of 9
4. File Processing
Write a static method evaluate that accepts as a parameter a Scanner containing a series of tokens representing a
numeric expression involving addition and subtraction and that returns the value of the expression. For example, if a
Scanner called data contains the following tokens:
4.2 + 3.4 - 4.1
The call of evaluate(data); should evaluate the result as (4.2+3.4-4.1) = (7.6-4.1) = 3.5 and should return this
value as its result. Every expression will begin with a real number and then will have a series of operator/number
pairs that follow. The operators will be either + (addition) or - (subtraction). As in the example above, there will be
spaces separating numbers and operators. You may assume the expression is legal.
Your program should evaluate operators sequentially from left to right. For example, for this expression:
7.3 - 4.1 - 2.0
your method should evaluate the operators as follows:
7.3 - 4.1 - 2.0 = (7.3 - 4.1) - 2.0 = 3.2 - 2.0 = 1.2
The Scanner might contain just a number, in which case your method should return that number as its result.
4 of 9
5. File Processing
Write a static method blackjack that accepts as its parameter a Scanner for an input file containing a hand of
playing cards, and returns the point value of the hand in the card game Blackjack.
A card has a rank and a suit. There are 13 ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. There are 4
suits: Clubs, Diamonds, Hearts, and Spades. A Blackjack hand's point value is the sum of its cards' point values. A
card's point value comes from its rank; the suit is irrelevant. In this problem, cards are worth the following points:
Rank Point Value
2-10 The card's rank (for example, a 7 is worth 7 points)
Jack (J), Queen (Q), King (K) 10 points each
Ace (A) 11 points (for this problem; simplified compared to real Blackjack)
The input file contains a single hand of cards, each represented by a pair of "<rank> <suit>" tokens. For example:
5 Diamonds
Q Spades
2 Spades 3 Hearts
Given the above input, your method should return 20, since the cards' point values are 5 + 10 + 2 + 3 = 20.
The input can be in mixed casing, have odd spacing between tokens, and can be split across lines. For example:
2 Hearts
j SPADES a Diamonds
2 ClUbS
A
hearts
Given the above input, your method should return 36, since the cards' point values are 2 + 10 + 11 + 2 + 11 = 36.
You may assume that the Scanner contains at least 1 card (two tokens) of input, and that no line will contain any
tokens other than valid card data. The real game of Blackjack has many other rules that you should ignore for this
problem, such as the notion of going "bust" once you exceed a score of 21.
5 of 9
6. Array Programming
Write a static method named allPlural that accepts an array of strings as a parameter and returns true only if
every string in the array is a plural word, and false otherwise. For this problem a plural word is defined as any
string that ends with the letter S, case-insensitively. The empty string "" is not considered a plural word, but the
single-letter string "s" or "S" is. Your method should return true if passed an empty array (one with 0 elements).
The table below shows calls to your method and the expected values returned:
Array Call and Value Returned
String[] a1 = {"snails", "DOGS", "Cats"}; allPlural(a1) returns true
String[] a2 = {"builds", "Is", "S", "THRILLs", "CS"}; allPlural(a2) returns true
String[] a3 = {}; allPlural(a3) returns true
String[] a4 = {"She", "sells", "sea", "SHELLS"}; allPlural(a4) returns false
String[] a5 = {"HANDS", "feet", "toes", "OxEn"}; allPlural(a5) returns false
String[] a6 = {"shoes", "", "socks"}; allPlural(a6) returns false
For full credit, your method should not modify the array's elements.
6 of 9
7. Array Programming
Write a static method named reverseChunks that accepts two parameters, an array of integers a and an integer
"chunk" size s, and reverses every s elements of a. For example, if s is 2 and array a stores {1, 2, 3, 4, 5, 6},
a is rearranged to store {2, 1, 4, 3, 6, 5}. With an s of 3 and the same elements {1, 2, 3, 4, 5, 6}, array
a is rearranged to store {3, 2, 1, 6, 5, 4}. The chunks on this page are underlined for convenience.
If a's length is not evenly divisible by s, the remaining elements are untouched. For example, if s is 4 and array a
stores {5, 4, 9, 2, 1, 7, 8, 6, 2, 10}, a is rearranged to store {2, 9, 4, 5, 6, 8, 7, 1, 2, 10}.
It is also possible that s is larger than a's entire length, in which case the array is not modified at all. You may assume
that s is 1 or greater (an s of 1 would not modify the array). If array a is empty, its contents should remain unchanged.
The following table shows some calls to your method and their expected results:
Array and Call Array Contents After Call
int[] a1 = {20, 10, 30, 60, 50, 40}; {10, 20, 60, 30, 40, 50}
reverseChunks(a1, 2);
int[] a2 = {2, 4, 6, 8, 10, 12, 14, 16}; {6, 4, 2, 12, 10, 8, 14, 16}
reverseChunks(a2, 3);
int[] a3 = {7, 1, 3, 5, 9, 8, 2, 6, 4, 10, 0, 12}; {9, 5, 3, 1, 7, 10, 4, 6, 2, 8, 0, 12}
reverseChunks(a3, 5);
int[] a4 = {1, 2, 3, 4, 5, 6}; {1, 2, 3, 4, 5, 6}
reverseChunks(a4, 8);
int[] a5 = {}; {}
reverseChunks(a5, 2);
7 of 9
8. Critters
Write a class Minnow that extends Critter from HW8, along with its movement and eating behavior. All other
aspects of Minnow use the defaults. Add fields, constructors, etc. as necessary to your class.
Minnow objects initially move in a S/E/S/E/... pattern. However, when a Minnow encounters food (when its eat
method is called), it should do all of the following:
• Do not eat the food.
• Start the movement cycle over. In other words, the next move after eat is called should always be South.
• Lengthen and reverse the horizontal portion of the movement cycle pattern.
The Minnow should reverse its horizontal direction and increase its horizontal movement distance by 1 for
subsequent cycles. For example, if the Minnow had been moving S/E/S/E, it will now move S/W/W/S/W/W. If
it hits a second piece of food, it will move S/E/E/E/S/E/E/E, and a third, S/W/W/W/W/S/W/W/W/W, and so on.
?
The following is an example timeline of a particular Minnow object's movement. The ??
timeline below is also drawn in the diagram at right. Underlined occurrences mark squares ??
where the Minnow found food. ???
???
• S, E, S, E (hits food) ?
????
• S, W, W, S, W, W, S (hits food) ????
• S, E, E, E, S, E, E, E, S, E (hits food) ??
• S (hits food) ?
??????
• S, E, E, E, E, E, S, E, E, E, E, E, ...
8 of 9
9. Classes and Objects
Suppose that you are provided with a pre-written class Date as // Each Date object stores a single
described at right. (The headings are shown, but not the method // month/day such as September 19.
bodies, to save space.) Assume that the fields, constructor, and // This class ignores leap years.
methods shown are already implemented. You may refer to them
or use them in solving this problem if necessary. public class Date {
private int month;
Write an instance method named bound that will be placed inside private int day;
the Date class to become a part of each Date object's behavior.
The bound method constrains a Date to within a given range of // Constructs a date with
dates. It accepts two other Date objects d1 and d2 as parameters; // the given month and day.
public Date(int m, int d)
d1's date is guaranteed to represent a date that comes no later in
the year than d2's date. // Returns the date's day.
The bound method makes sure that this Date object is between public int getDay()
d1's and d2's dates, inclusive. If this Date object is not between
// Returns the date's month.
those dates inclusive, it is adjusted to the nearest date in the public int getMonth()
acceptable range. The method returns a result of true if this
Date was within the acceptable range, or false if it was shifted. // Returns the number of days
// in this date's month.
For example, given the following Date objects: public int daysInMonth()
Date date1 = new Date(7, 12);
Date date2 = new Date(10, 31); // Modifies this date's state
Date date3 = new Date(9, 19); // so that it has moved forward
Date bound1 = new Date(8, 4); // in time by 1 day, wrapping
Date bound2 = new Date(9, 26); // around into the next month
Date bound3 = new Date(12, 25); // or year if necessary.
// example: 9/19 -> 9/20
The following calls to your method should adjust the given Date // example: 9/30 -> 10/1
objects to represent the following dates and should return the // example: 12/31 -> 1/1
following results: public void nextDay()
call date becomes returns
date1.bound(bound1, bound2) 8/4 false
// your method would go here
date2.bound(bound1, bound2) 9/26 false
date3.bound(bound1, bound3) 9/19 true }
date2.bound(bound3, bound3) 12/25 false
9 of 9
Other documents randomly have
different content
deer, antelope, bear, squirrel, porcupines and all the other animals.
Then he made out of other people all the different kinds of snakes
and reptiles and insects and birds and fishes. Then he wanted trees
and plants and flowers, and he turned some of the people into these
things. Of every man or woman that he seized he made something
according to its value. When he had done he had used up so many
people he was scared. So he set to work and made a new lot of
people, some to live here and some to live everywhere. And he gave
to each family its own language and tongue and its own place to
live, and he told them where to live and the sad distress that would
come upon them if they mixed up their tongues by intermarriage.
Each family was to live in its own place and while all the different
families were to be friends and live as brothers, tied together by
kinship, amity and concord, there was to be no mixing of bloods.
Thus were settled the original inhabitants on the coast of Southern
California by Siwash, the god of the earth, and under the captaincy
of Uuyot.
The language of the Palas is simple, easy to pronounce, regular in its
grammar, and much richer in the number of its words than is usually
believed of Indian idioms. It comprises nearly 5,000 different words,
or more than the ordinary vocabulary of the average educated white
man or newspaper writer. The gathering of these words was done by
the late P. S. Spariman, for years Indian trader and storekeeper, at
Rincon, who was an indefatigable student of both words and
grammar. His manuscript is now in the keeping of Professor Kroeber,
and will shortly be published by the University of California. Dr.
Kroeber claims that it is one of the most important records ever
compiled of the thought and mental life of the native races of
California.
CHAPTER IV.
Every lover of the artistic and the picturesque on first seeing the
bell-tower of Pala stands enraptured before its unique personality.
And this word "personality" does not seem at all misapplied in this
connection. Just as in human beings we find a peculiar charm in
certain personalities that it is impossible to explain, so is it with
buildings. They possess an individuality, quality, all their own, which,
sometimes, eludes the most subtle analysis. Pala is of this character.
One feels its charm, longs to stand or sit in contemplation of it.
There is a joy in being near to it. Its very proximity speaks peace,
contentment, repose, while it breathes out the air of the romance of
the past, the devoted love of its great founder, Peyri, the pathos of
the struggles it has seen, the loss of its original Indians, its long
desertion, and now, its rehabilitation and reuse in the service of
Almighty God by a band of Indians, ruthlessly driven from their own
home by the stern hand of a wicked and cruel law to find a new
home in this gentle and secluded vale.
As far as I know or can learn, the Pala Campanile, from the
architectural standpoint, is unique. Not only does it, in itself, stand
alone, but in all architecture it stands alone. It is a free building,
unattached to any other. The more one studies the Missions from the
professional standpoint of the architect the more wonderful they
become. They were designed by laymen—using the word as a
professed architect would use it. For the padres were the architects
of the Missions, and when and where and how could they have been
trained technically in the great art, and the practical craftsmanship
of architecture? Laymen, indeed, they were, but masters all the
same. In harmonious arrangement, in bold daring, in originality, in
power, in pleasing variety, in that general gratification of the senses
that we feel when a building attracts and satisfies, the priestly
architects rank high. And, as I look at the Pala Campanile, my mind
seeks to penetrate the mind of its originator. Whence conceived he
the idea of this unique construction? Was it a deliberate conception,
viewed by a poetic imagination, projected into mental cognizance
before erection, and seen in its distinctive beauty as an original and
artistic creation before it was actually visualized? Or was it mere
accident, mere utilitarianism, without any thought of artistic effect?
We must remember that, to the missionary padres, a bell-tower was
not a luxury of architecture, but an essential. The bells must be
hung up high, in order that their calling tones could penetrate to the
farthest recesses of the valley, the canyons, the ravines, the foothills,
wherever an Indian ear could hear, an Indian soul be reached.
Indians were their one thought—to convert them and bring them
into the fold of Mother Church their sole occupation. Hence with the
chapel erected, the bell-tower was a necessary accompaniment, to
warn the Indian of services, to attract, allure and draw the stranger,
the outsider, as well as to remind those who had already entered the
fold. In addition its elevation was required for the uplifting of the
cross—the Emblem of Salvation.
It is evident, from the nature of the case, that here was no great
and studious architectural planning, as at San Luis Rey. This was
merely an asistencia, an offshoot of the parent Mission, for the
benefit of the Indians of this secluded valley, hence not demanding a
building of the size and dignity required at San Luis. But though less
important, can we conceive of it as being unimportant to such a
devoted adherent to his calling as Padre Peyri? Is it not possible he
gave as much thought to the appearance of this little chapel as he
did to the massive and kingly structure his genius created at the
Mission proper? I see no reason to question it. Hence, though it
does sometimes occur to me that perhaps there was no such
planning, no deliberate intent, and, therefore, no creative genius of
artistic intuition involved in its erection, I have come to the
conclusion otherwise. So I regard Pala and its free-standing
Campanile as another evidence of devoted genius; another
revelation of what the complete absorption of a man's nature to a
lofty ideal—such, for instance, as the salvation of the souls of a race
of Indians—can enable him to accomplish. One part of his nature
uplifted and inspired by his passionate longings to accomplish great
things for God and humanity, all parts of his nature necessarily
become uplifted. And I can imagine that the good Peyri awoke one
morning, or during the quiet hours of the night, perhaps after a
wearisome day with his somewhat wayward charges, or after a sleep
induced by the hot walk from San Luis Rey, with the picture of this
completed chapel and campanile in his mind. With joy it was
committed to paper—perhaps—and then, hastily was constructed, to
give joy to the generations of a later and alien race who were
ultimately to possess the land.
On the other hand may it not be possible that the Pala Campanile
was the result of no great mental effort, merely the doing of the
most natural and simple thing?
Many a man builds, constructs, better than he knows. It has long
been a favorite axiom of my own life that the simple and natural are
more beautiful than the complex and artificial. Just as a beautiful
woman, clothed in dignified simplicity, in the plainest and most
unpretentious dress, will far outshine her sisters upon whose
costumes hours of thought in design and labor, and vast sums for
gorgeous material and ornamentation have been expended, so will
the simply natural in furniture, in pottery, in architecture make its
appeal to the keenly critical, the really discerning.
Was Peyri, here, the inspired genius, fired with the sublime audacity
that creates new and startling revelations of beauty for the delight
and elevation of the world, or was he but the humble, though
discerning, man of simple naturalness who did not know enough to
realize he was doing what had never been done before, and thus,
through his very simplicity and naturalness, stumbling upon the
daring, the unique, the individualistic and at the same time, the
beautiful, the artistic, the competent?
In either case the effect is the same, and, whether built by accident
or design, the result of mere utilitarianism or creative genius, the
world of the discerning, the critical, and the lovers of the beautifully
unique, the daringly original, or the simply natural, owe Padre Peyri
a debt of gratitude for the Pala Campanile.
The height of the tower above the base was about 35 feet, the
whole height being 50 feet. The wall of the tower was three feet
thick.
A flight of steps from the rear built into the base, led up to the bells.
They swung one above another, and when I first saw them were
undoubtedly as their original hangers had placed them. Suspended
from worm-eaten, roughly-hewn beams set into the adobe walls,
with thongs of rawhide, one learned to have a keener appreciation
of leather than ever before. Exposed to the weather for a century
sustaining the heavy weight of the bells, these thongs still do
service.
One side of the larger bell bears an inscription in Latin, very much
abbreviated, as follows:
Stus Ds Stus Ftis Stus Immortlis Micerere Nobis. An. De 1816 I. R.
which being interpreted means, "Holy Lord, Holy Most Mighty One,
Holy Immortal One, Pity us. Year of 1816. Jesus Redemptor."
The other side contains these names in Spanish: "Our Seraphic
Father, Francis of Asissi. Saint Louis, King. Saint Clare, Saint Eulalia.
Our Light. Cervantes fecit nos—Cervantes made us."
The smaller bell, in the upper embrasure, bears the inscription:
"Sancta Maria ora pro nobis"—Holy Mary, pray for us.
The Campanile stands just within the cemetery wall. Originally it
appeared to rest upon a base of well-worn granite boulders, brought
up from the river bed, and cemented together. The revealing and
destroying storm of 1916 showed that these boulders were but a
covering for a mere adobe base, which—as evidenced by its
standing for practically a whole century—its builders deemed secure
enough against all storms and strong enough to sustain the weight
of the superstructure. Resting upon this base which was 15 feet
high, was the two-storied tower, the upper story terraced, as it were,
upon the lower, and smaller in size, as are or were the domes of the
Campaniles of Santa Barbara, San Luis Rey, San Buenaventura and
Santa Cruz. But at Pala there were no domes. The wall was pierced
and each story arched, and below each arch hung a bell. The apex
of the tower was in the curved pediment style so familiar to all
students of Mission architecture, and was crowned with a cross. By
the side of this cross there grew a cactus, or prickly pear. Though
suspended in mid-air where it could receive no care, it has flourished
ever since the American visitor has known it, and my ancient Indian
friends tell me it has been there ever since the tower was built. This
assertion may be the only authority for the statement made by one
writer that:
One morning just about a century ago, a monk fastened a cross in
the still soft adobe on the top of the bell tower and at the foot of the
cross he planted a cactus as a token that the cross would conquer
the wilderness. From that day to this this cactus has rested its spiny
side against that cross, and together—the one the hope and the
inspiration of the ages, and the other a savage among the scant
bloom of the desert—they have calmly surveyed the labor, the
opulence, the decline, and the ruin of a hundred years.
One writer sweetly says of it:
It is rooted in a crack of the adobe tower, close to the spot where
the Christian symbol is fixed, and seemed, I thought, to typify how
little of material substance is needed by the soul that dwells always
at the foot of the cross.
Another story has it that when Padre Peyri ordered the cross placed,
it was of green oak from the Palomar mountains. Naturally, the birds
came and perched on it, and probably nested at its foot, using mud
for that purpose. In this soft mud a chance seed took lodgment and
grew.
Be this as it may the birds have always frequented it since I have
known it, some of them even nesting in the thorny cactus slabs. On
one visit I found a tiny cactus wren bringing up its brood there,
while on another occasion I could have sworn it was a mocking-bird,
for it poured out such a flood of melody as only a mocking-bird
could, but whether the nest there belonged to the glorious songster,
or to some other feathered creature, I could not watch long enough
to tell.
Other birds too, have utilized this tower from which to launch forth
their symphonies and concertos. In the early mornings of several of
my visits, I have gone out and sat, perfectly entranced, at the rich
torrents of exquisite and independent melody each bird poured forth
in prodigal exuberance, and yet which all combined in one chorus of
sweetness and joy as must have thrilled the priestly builder, if, today,
from his heavenly home he be able to look down upon the work of
his hands.
It must not be forgotten, in our admiration for the separate-standing
Campanile of Pala, and the general belief that it is the only example
in the world, that others of the Franciscan Missions of California
practically have the same architectural feature. While the well-known
campanile of the Mission San Gabriel is not, in strict fact, a separate
standing one, the bell-tower itself is merely an extension of the
mission wall and practically stands alone. The same method of
construction is followed at Mission Santa Inés. The fachada of the
church is extended, to the right, as a wall, which is simply a
detached belfry. And, as is well known, the campanile of San Juan
Capistrano, erected after the fall of the bell-tower of the grand
church in the earthquake of 1812, is a mere wall, closing up a
passage between two buildings, with pierced apertures in which the
bells are hung.
CHAPTER V.
Further Desolation
testbankfan.com