Building Java Programs A Back to Basics Approach 4th Edition Reges Test Bank instant download
Building Java Programs A Back to Basics Approach 4th Edition Reges Test Bank instant download
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/basics-of-media-writing-a-
strategic-approach-2nd-edition-kuehn-test-bank/
Research Methods For Business A Skill Building Approach
7th Edition Sekaran Test Bank
https://testbankfan.com/product/research-methods-for-business-a-
skill-building-approach-7th-edition-sekaran-test-bank/
https://testbankfan.com/product/designing-and-managing-programs-
an-effectiveness-based-approach-5th-edition-kettner-test-bank/
https://testbankfan.com/product/business-and-society-a-strategic-
approach-to-social-responsibility-4th-edition-thorne-test-bank/
https://testbankfan.com/product/medical-terminology-for-health-
care-professionals-a-word-building-approach-9th-edition-rice-
test-bank/
https://testbankfan.com/product/java-foundations-introduction-to-
program-design-and-data-structures-4th-edition-lewis-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
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of Moses Tod:
Legende
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: German
LEGENDE
VON
RUDOLF KAYSER
MÜNCHEN
KURT WOLFF VERLAG
B ü c h e re i „ D e r J ü n g s t e Ta g “ , B a n d 8 6
Gedruckt bei Poeschel & Trepte in Leipzig
Copyright 1921
by Kurt Wolff Verlag A.-G. München
Für Werner Schendell
in großer Freundschaft
Und der Herr sprach zu ihm: Dies ist das Land,
das ich Abraham, Isaak und Jakob geschworen
habe, und gesagt: Ich will es deinem Samen
geben. Du hast es mit deinen Augen gesehen;
aber du wirst nicht hinübergehen.
Also starb Mose, der Knecht des Herrn,
daselbst im Lande der Moabiter nach dem Worte
des Herrn.
Noch drei Tage und drei Nächte mußte das Volk durch die Wüste
ziehen, ehe es den Fuß des Gebirges erreichte. Dort angelangt, lebte
man ganz in den Vorstellungen dessen, was jenseits der Berge auf
Israel wartete. Alle Herrlichkeiten Mizrajims steigerte man zu einer
phantastischen Fülle von Gaben, Freude und Schönheit und preßte
die Seelen so voll von ihnen, daß sie müde wie überladene
Weinstöcke sich neigten. Begehren glänzte von den Gesichtern und
machte sie feindlich und verschlagen. Die Blicke suchten, dem
Bruder die Pläne zu rauben, um alle Vorteile des gesegneten Landes
auf sich vereinigen zu können. So wurden sie habgierig, zänkisch
und klein. Sie riefen sich Schimpfworte und Prahlereien zu.
„Ich werde die größten Weiden am Flusse Jordan haben; Herden
von Rindern, Schafen und Ziegen, unzählig wie die Herden des
Stammvaters Abraham. Du aber wirst in der Stadt hausen, in einer
engen, schmutzigen Kammer und dich kümmerlich nähren von
deinem armseligen Handwerk.“
„An meiner Tür wirst du betteln, und ich werde dich fortpeitschen
lassen wie einen räudigen Hund.“
„Ich werde ein Handelshaus haben, das seine Karawanen nach
Babylon, Damaskus und Kairo schickt.“
„Ich werde Gold aufhäufen, gleißendes, gelbes Gold, zu Bergen,
höher als der Libanon, und wenn ich sterben werde, so nehm’ ich
das Gold und streu’ es zuvor in den Jordan, damit niemand nach mir
es haben wird.“
Die Entbehrungen ihres bisherigen Lebens strömten sich in
solchen Wünschen aus. Ihre Herzen waren hart und verschlossen
geworden, und wo sonst Hilfe und Güte waren, herrschte Neid und
Mißtrauen. So standen sie schon in dem Schatten kommenden
Besitzes und waren eitel und schlecht. Sie klagten nicht mehr, aber
sie beteten auch nicht mehr; sie träumten und planten, wie Räuber
und Eroberer es tun.
Der letzte Abend in der Wüste war gekommen. Die Israeliten ruhten
vor ihren Lagerfeuern und sprachen, zankten und ereiferten sich.
Plötzlich erschien mitten in ihrem Kreis, steinern und groß, den
breiten Körper wie eine Brücke zwischen Himmel und Erde gespannt,
den Blick in jede Seele gewandt, Mose, ihr Führer.
Schnell waren die Gespräche verstummt. Man versuchte, die
schlechten Worte und Blicke zu verbergen, wie ein Dieb unter seinen
Gewändern die gestohlenen Gegenstände verbirgt. Ein großes und
ängstliches Schweigen lagerte unter dem nächtlichen Himmel.
„Führer, sprich!“
Mose machte eine Gebärde, aber er sprach noch nicht. Auf seinem
Gesicht stand tiefe Klarheit und Feierlichkeit. Er wandte sich
Menschen, Bergen und Wüste zu, und jeder sah, daß ein Erlebnis
seine Seele schwellte, groß und erschütternd wie einst am Sinai. Da
erinnerte sich mancher an Moses Blicke und Worte, als er die Tafeln
zerbrach, da das Volk von Gott abgefallen war. Furcht und
Beschämung griffen um sich. Viele empfanden Reue, viele Furcht vor
kommenden Vorwürfen, denn Mose kannte jede Sünde.
Sie lagerten sich in einem großen Kreis. Die giftige Besitzgier war
schnell verschwunden. Auf den Gesichtern stand Demut und
Feierlichkeit. Alle empfanden ihr Auserwähltsein durch Gott, ihre
Gemeinschaft und Einsamkeit unter den Völkern.
Mose trat in die Mitte des Kreises. Langsam und träumerisch
erklangen die ersten Worte, um dann in mächtiger Steigerung
emporzubrausen. Doch kein Wort des Vorwurfs erklang.
„Gesegnet seist du, Volk Israel, da das Ende deiner Wanderung
erreicht ist. Zweimal wird die Sonne noch auf- und untergehen, dann
schreitet dein Fuß über üppiges Land, das Jahve, dein Gott, dir
verheißen hat. Deine Herden weiden auf heimatlichem Boden,
Brunnen rauschen in deinen Dörfern, jeder wird seinem Tagewerk
nachgehen. So werdet ihr Ruhe und Freuden finden. Auch Gott wird
zur Ruhe kommen, und seine Lade hinter Tempelmauern stehen.
Vierzig Jahre habe ich dich durch Wüste und Entbehrung geführt,
wie Gott es befahl. Nun sind wir am Ende. Der Segen Jahves wird
dich weiter geleiten.
Ich habe das Land eurer Kinder gesehen. Sonne strahlt über
Weiden und Seen. Wälder stehen tief und dunkel. Im Westen
erglänzt das Meer. Jahreszeiten bescheren Blüte, Frucht und Ernte.
Ewiges Werden und Vergehen randet um Israel, und du wirst
bleiben, mein seßhaftes Volk.
Doch meine Zeit ist erfüllt. Gottes Hände graben mein Grab in den
Bergen. Ihr zieht in das Land der Weiden und grünen Wiesen. Doch
Gottes Wort lastet eisern auf euch. Ihr wart auserwählt unter allen
Völkern der Erde, den Geist zu erkennen und zu verkünden. Verrat
wird dennoch unter euch herrschen, und der Zorn Gottes, entflammt
über eure Untreue, euch strafen und in alle Länder vertreiben.
Dich, Josua, Sohn Nuns, hat Gott erwählt, von nun an dieses
Volkes Führer zu sein. Einsicht beleuchte deinen Weg. Kummer und
Verzweiflung bleiben dir fern, bis auch an dich das Wort Gottes
ergeht, das dich von den schwellenden Jordanufern fortruft in sein
ewiges Reich.“
Bei diesen Worten zitterte ein Volk. Abschied, Mahnung und
Schicksal sprachen, fesselten Mensch an Mensch, gaben ihrem
Leben Weite, Ungewißheit und Not.
Bruder, Schwester, Stunde, Land und Gott!
Alle Geheimnisse schwanden, Wünsche starben, Bilder lösten sich
ab. Erinnerungen standen auf, Ängste zuckten, Stimmen jammerten,
und alles schlug zusammen in dieser einen Erkenntnis,
unwahrscheinlicher als Weltuntergänge und Wundertaten: der
Führer stirbt!
Da ist nicht Raum für ein anderes Gefühl, da ist nicht Zeit für
andere Gedanken, da ist nur Augenblick, weit, dumpf und gefährlich,
und in seiner Mitte die eine Gestalt: schwer, gereckt, einsam,
tausende Blicke tragend, Turm über der Wüste, Mensch über dem
Volk.
Ein Schweigen griff um sich, das Blut und Atem stocken ließ. In
diesem Kauern, Liegen, Warten der Tausende geschah noch einmal
Heiligkeit, Demut und Leid.
Ist das unser Ziel?
Wir Wanderer, Armen, Gott-Träger am Tore des Paradieses. Wir
braunen Wüstentiere, hager, von Jahve getrieben und geführt,
auserkoren unter allen Völkern der Erde. Früchte warten unser,
Weide, Milch, Honig, ein gesegnetes Land. Aber der Führer schreitet
nicht mehr voran, ebnet nicht Wege, läßt Jahves Wort nicht steigen
durch Gebirg, Täler und Feinde. Wir sind die Verlassenen, die
rissigen Tafeln der Verkündung, blökende Herde, beschwert und
zerdrückt von der blutigen Last unseres Gottes.