[Ebooks PDF] download Java Programming Exercises Volume One Language Fundamentals and Core Concepts 1st Edition Christian Ullenboom full chapters
[Ebooks PDF] download Java Programming Exercises Volume One Language Fundamentals and Core Concepts 1st Edition Christian Ullenboom full chapters
com
https://ebookname.com/product/java-programming-exercises-
volume-one-language-fundamentals-and-core-concepts-1st-
edition-christian-ullenboom/
OR CLICK HERE
DOWLOAD NOW
https://ebookname.com/product/programming-language-design-
concepts-1st-edition-findlay/
ebookname.com
https://ebookname.com/product/effective-java-programming-language-
guide-1st-edition-joshua-bloch/
ebookname.com
https://ebookname.com/product/java-programming-comprehensive-concepts-
and-techniques-3rd-edition-gary-b-shelly/
ebookname.com
https://ebookname.com/product/blood-noir-anita-blake-vampire-
hunter-16-1st-edition-laurell-k-hamilton/
ebookname.com
Surgical Anatomy and Techniques to the Spine 2nd Edition
Daniel H. Kim Et Al.
https://ebookname.com/product/surgical-anatomy-and-techniques-to-the-
spine-2nd-edition-daniel-h-kim-et-al/
ebookname.com
https://ebookname.com/product/multicultural-psychology-6th-edition-
jeffery-scott-mio/
ebookname.com
https://ebookname.com/product/electrical-insulation-for-rotating-
machines-1st-edition-greg-stone/
ebookname.com
https://ebookname.com/product/pauline-frommer-s-washington-d-c-
pauline-frommer-guides-1st-edition-james-t-yenckel/
ebookname.com
https://ebookname.com/product/organizational-behaviour-1st-edition-
daniel-king/
ebookname.com
The Heroic Slave A Cultural and Critical Edition Frederick
Douglass (Editor)
https://ebookname.com/product/the-heroic-slave-a-cultural-and-
critical-edition-frederick-douglass-editor/
ebookname.com
Java Programming Exercises
Take the first step in raising your coding skills to the next level, and test your Java knowledge on tricky
programming tasks, with the help of the pirate Captain CiaoCiao. This is the first of two volumes which
provide you with everything you need to excel in your Java journey, including tricks that you should know
in detail as a professional, as well as intensive training for clean code and thoughtful design that carries
even complex software.
Features:
With numerous best practices and extensively commented solutions to the tasks, these books provide the
perfect workout for professional software development with Java.
Java Programming Exercises
Volume One: Language Fundamentals and
Core Concepts
Christian Ullenboom
Designed cover image: Mai Loan Nguyen Duy, Rheinwerk Verlag GmbH
©2023 Christian Ullenboom. First published in the German language under the title “Captain CiaoCiao erobert Java”
(ISBN 978‑3‑8362‑8427‑1) by Rheinwerk Verlag GmbH, Bonn, Germany.
Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been
acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or
utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including
photocopying, microfilming, and recording, or in any information storage or retrieval system, without written
permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the
Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978‑750‑8400. For works that are
not available on CCC please contact mpkbookspermissions@tandf.co.uk
Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for
identification and explanation without intent to infringe.
DOI: 10.1201/9781003454502
Typeset in Times
by codeMantra
Introduction 1
Previous Knowledge and Target Audience 1
Working with This Book 2
The Suggested Solutions 2
Use of This Book 3
Required Software 3
Used Java Version in the Book 4
JVM 4
Development Environment 4
Conventions 4
Helping Captain CiaoCiao and Bonny Brain 5
2 Imperative Programming 9
Screen Output 9
Learn about the SVG Specification 9
Write an SVG Circle on the Console ⭑ 10
Variables and Data Types 11
Access Variables and Output Their Assignments ⭑ 12
Quiz: Value Ranges ⭑ 12
Quiz: Does This Add Up? ⭑⭑⭑ 12
Generate Random Circles ⭑ 13
Quiz: Dazed and Confused ⭑ 14
Process User Input ⭑ 14
Expressions, Operands, and Operators 14
Quiz: Check In-Between ⭑ 14
Check If Loot Can Be Shared Fairly ⭑ 15
Do Two Numbers Share the Same Digit? ⭑⭑ 15
Convert Currency Amount to Coins ⭑⭑ 15
One Bottle of Rum, Ten Bottles of Rum ⭑ 16
Quiz: The Zero Effect ⭑ 17
v
vi Contents
Control Flow 18
Payday ⭑ 18
Quiz: Wrong Branching ⭑ 18
Convert Liters ⭑⭑ 19
Create SVG Circles with Random Colors ⭑ 19
Quiz: To Which Block Does the Else Belong? ⭑⭑ 20
Quiz: Recognize Negative Days and Hours ⭑ 20
Evaluate Input Strings for Approval ⭑ 20
Rewrite Switch Statement to Switch Expression ⭑ 21
Loops 21
Create Rotated SVG Rectangles ⭑ 21
Create SVG‑Pearl‑Chain ⭑ 22
Sum Numbers from the Command Line ⭑ 23
Go through a Mathematical Phenomenon ⭑ 24
Quiz: How Many Stars? ⭑ 24
Calculate Products for Faculties ⭑ 25
Determine If a Number Is Formed by Factorial ⭑ 25
Find the Smallest and Largest Digit of a Number ⭑ 26
Quiz: Not Like This from 1 to 100 ⭑⭑ 27
A Flag in the Wind through Nested Loops ⭑ 28
Output Simple Chessboard ⭑ 28
It’s Christmastime: Displaying Trees with Ornaments ⭑ 29
Draw Fishy Stitching Motifs ⭑ 30
Trying Instead of Thinking ⭑⭑ 31
Get the Number of Digits of a Number ⭑⭑ 32
Methods 33
Drawing Hearts ⭑ 33
Implement Overloaded Line Methods ⭑ 34
Standing Straight ⭑ 34
Create a Multiplication Table ⭑ 35
Cistercian Numerals Script ⭑⭑⭑ 36
Quiz: What Does Ding‑Dong Do? (Recursion) ⭑⭑ 37
Quiz: Repdigit (Recursion) ⭑⭑ 37
Calculate Collatz Sequence (Recursion) ⭑ 38
Ancient Egyptian Multiplication (Recursion) ⭑⭑ 38
Suggested Solutions 40
Write an SVG Circle on the Console ⭑ 40
Access Variables and Output Their Assignments 41
Quiz: Value Ranges 42
Quiz: Does This Add Up? 43
Generate Random Circles 43
Quiz: Dazed and Confused 44
Process User Input 44
Quiz: Check In-Between 44
Check If Loot Can Be Shared Fairly 45
Do Two Numbers Share the Same Digit? 45
Convert Currency Amount to Coins 46
One Bottle of Rum, Ten Bottles of Rum 47
Quiz: The Zero Effect 47
Payday 47
Quiz: Wrong Branching 48
Contents vii
Convert Liters 48
Create SVG Circles with Random Colors 49
Quiz: To Which Block Does the Else Belong? 50
Quiz: Recognize Negative Days and Hours 50
Evaluate Input Strings for Approval 51
Rewrite Switch Statement to Switch Expression 52
Create Rotated SVG Rectangles 52
Create SVG‑Pearl‑Chain 53
Sum Numbers from the Command Line 53
Go through a Mathematical Phenomenon 54
Quiz: How Many Stars? 55
Calculate Products for Faculties 55
Determine If a Number Is Formed by Factorial 57
Find the Smallest and Largest Digit of a Number 58
Quiz: Not Like This from 1 to 100 58
A Flag in the Wind through Nested Loops 59
Output Simple Chessboard 60
It’s Christmastime: Displaying Trees with Ornaments 60
Draw Fishy Stitching Motifs 61
Trying Instead of Thinking 62
Get the Number of Digits of a Number 63
Drawing Hearts 65
Implement Overloaded Line Methods 65
Standing Straight 66
Create a Multiplication Table 68
Cistercian Numerals Script 69
Quiz: What Does Ding‑Dong Do? (Recursion) 72
Quiz: Repdigit (Recursion) 72
Calculate Collatz Sequence (Recursion) 73
Ancient Egyptian Multiplication (Recursion) 75
4 Arrays 86
Everything Has a Type 86
Quiz: Array Types ⭑ 86
One‑Dimensional Arrays 87
viii Contents
Appendix A: Most Frequent Types and Methods in the Java Universe 295
A.1 Packages with the Most Common Types 295
A.2 100 Most Common Types 296
A.3 100 Most Common Methods 299
A.4 100 Most Common Methods Including Parameter List 302
Exploring the Variety of Random
Documents with Different Content
'Yes, by Jove! but in the time to come?'
'Tiresome work I find that, with all my zeal for the service,' observed
Hammersley, as the entire cavalry force moved off about four in the
morning, when the sky and landscape were alike dark. 'We have much
bodily endurance, and run enormous risks which the people at home don't
understand or fully appreciate, because our antagonists are naked savages,
though second to no men in the world for reckless valour; thus honour may
be accorded to us but scantily and grudgingly, because they are savages and
not civilised enemies, or, as some one says of the days of the Great Duke,
when so many thousand men in red coats and blue breeches met and beat so
many thousand men in blue coats and red breeches.'
General Marshall, with the King's Dragoon Guards and 17th Lancers,
had reconnoitred the country in advance as far as the Upoko River, and
there effected a junction with Buller's command on the same ground where
the latter had escaped the ambuscade referred to.
Above the vast mountain opposite, where the Upoko (a tributary of the
great White Umvulosi, which flows towards the sea) was rolling in golden
sheen between banks clothed with date palms, Kaffir plums, flowering
acacias, and thornwood, the uprisen sun was shining in all his glory. The
mountain was torn by ravines and studded with mimosa groups. On the left
of the troops rose the vast Inhlatzatye, or mountain of greenstone, turned to
crimson in the morning sun, its base clothed with lovely pasture, and twenty
miles in its rear was known to be Ulundi, the great military kraal of
Cetewayo, the chief object of the advance.
In the immediate foreground was the force of cavalry, with all their
white helmets and sword blades shining in the sun, the dark blue of the
Lancers, and the sombre uniforms of the Irregular Horse, relieved and
varied by the bright scarlet of the King's Dragoon Guards and the mimosa-
coloured tunics of the Mounted Infantry.
'Buller's Horse to the left!' cried the officer of that name, digging spurs
into his charger; 'Whalley's to the right! Frontier Light Horse and
Hammersley's Mounted Infantry the centre!'
Uncovering to the flanks, the formation was made at a canter, and the
forward movement began. During the morning Florian had more than once
(till his men required his attention) an unpleasant sense of the presence of
two secret enemies on the ground, which made him look frequently to
where the oddly costumed volunteer troopers were advancing, and before
that day's fighting was quite over he had bitter cause to know that both were
in the field.
The 1st King's Dragoon Guards had been quartered in the same barracks
with the regiment to which these two deserters belonged, and, feeling
themselves now in hourly expectation of recognition by some of them, the
camp of the Second Division had become perilous for the two desperadoes,
and on that day they had resolved to 'levant,' but not before effecting their
villainous purpose, if possible.
They knew well that by the rules of the service, at foreign stations, when
there is no doubt as to the identity of a deserter, he is sent at once to his own
corps to be dealt with there; moreover, they know that the fact of their
serving with the Volunteer Horse constituted another crime—that of
fraudulent enlistment; and neither had any desire to be tied to the wheel of a
field-piece and flogged as an example to others, for that punishment had not
been quite abandoned yet.
While Colonel Buller's force was advancing, the Zulus had moved off by
companies in singularly regular formation, and taken post in the rocky
ravines at the base of the Euzangonyan Hill, which was covered with thick
scrub and high feathery reeds, that swayed to and fro in the wind like a
mighty cornfield.
After crossing the river, the Irregulars and Mounted Infantry at full speed
advanced to within three hundred yards of the foe, and leaped from their
saddles, with rifles unslung. The horses were then led forward out of fire, or
nearly so, by every third file, told off for that purpose.
He ordered his bugle to sound the 'retire' and the whole to recross the
river, but not before several men were killed or wounded, with fifteen
horses placed hors de combat; then the Queen's cavalry were ordered to
advance to the attack with lance and sword.
From the Euzangonyan Hill the Zulus were now firing heavily, but as
their rifles were all wrongly sighted—if sighted at all—their bullets went
high into the air. Between these and Lowe spread a mealie-field, which he
believed to be full of other Zulus, and resolved to let all who might be
lurking there feel what the point of a lance is, he rode straight at it.
After punishing them severely, the cavalry were recalled, but not before
there were some casualties among the Lancers, whose adjutant, Lieutenant
Frith—a favourite officer—was shot through the heart, and brought to camp
dead across the saddle of his charger.
'Retire by alternate squadrons!' was now the order for the cavalry, and
beautifully and steadily was the movement executed.
'Fours about—trot,' came the order in succession from the leaders of the
even and odd squadrons.
A front was thus kept to the Zulus, but the hope to lure them from their
fastnesses by a movement they had never seen before, and to have a chance
of attacking them in the open, proved vain; and upon broken and steep
ground, on which it would have been impossible for any cavalry force to
assail them, they were seen swarming in vast black hordes round the flanks
of the Euzangonyan Hill, and still maintaining a sputtering but distant
though defiant fire, while the cavalry and other mounted men fell back
towards their respective columns; and now it was that the calamitous
outrage we have hinted at occurred.
'Those rash fools will get knocked on the head if they don't come back,'
said Hammersley to Florian, as they were riding leisurely now at a little
distance in rear of their men. 'They are nearly six hundred yards off. Well,
we have not got even a scratch to-day,' he added, laughing, as he
manipulated and proceeded to light a cigar; 'and now to get back to camp
and have a deep drink of bitter beer. By Jove, I am thirsty as a bag of sand.'
Again the 'retire' was sounded, now by two trumpeters together, but
without avail apparently.
At that moment two rifle-shots came upon the speakers, delivered by the
very men in question, and then they were seen to gallop at full speed, not
after the retreating column, but at an angle towards the north-west, on
perceiving that their shots had taken fatal effect; for Hammersley, struck by
one, fell from his saddle on his face, and rolled over apparently in mortal
agony, while Florian felt Tattoo give a kind of writhing bound under him
and nearly topple over on his forehead till recovered by the use of spur and
bridle-bit. Florian at once dismounted, for the horse was seriously
wounded; but he could only give a despairing glance at his friend, if he
meant to act decisively and avenge him.
'These scoundrels are deserters doubly—I know; follow me, men, we
have not a moment to lose!' cried Florian, in a voice husky with rage, grief,
and excitement, as he leaped upon poor Hammersley's horse; and with a
section of four men, one of whom was Tom Tyrrell, he spurred after them at
full speed, without waiting for orders given or permission accorded.
He never doubted for a moment that they were Josh Jarrett and Dick of
the Droogveldt, who were boldly attempting to escape in the face of the
column after failing to shoot himself, and who had now fully thousand
yards start of him and his pursuing party.
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.
• 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.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com