Head First Java a brain-Friendly Guide Kathy Sierra and Bert Bates


match the candidate block of code



Download 17,18 Mb.
Pdf ko'rish
bet17/90
Sana22.06.2022
Hajmi17,18 Mb.
#693704
1   ...   13   14   15   16   17   18   19   20   ...   90
Bog'liq
(Head Up) Kathy Sierra Bert Bates - Head First Java, 3rd Edition Early Release-O\'Reilly Media, Inc. (2021)

match the candidate block of code
(on the left), 
with
the output
that you’d see if the block were inserted. Not all the lines of
output will be used, and some of the lines of output might be used more
than once. Draw lines connecting the candidate blocks of code with their
matching command-line output. (The answers are at the end of the chapter).



Pool Puzzle
Your 
job
is to take code snippets from the pool and place them into the
blank lines in the code. You may 
not
use the same snippet more than once,
and you won’t need to use all the snippets. Your 
goal
is to make a class that
will compile and run and produce the output listed. Don’t be fooled—this
one’s harder than it looks.
Output
class PoolPuzzleOne { 
public static void main(String [] args) { 
int x = 0; 


while ( __________ ) { 
_____________________________ 
if ( x < 1 ) { 
___________________________ 

_____________________________ 
if ( __________ ) { 
____________________________ 
___________ 

if ( x == 1 ) { 
____________________________ 

if ( ___________ ) { 
____________________________ 

System.out.println(““); 
____________ 


}
Note
Each snippet from the pool can be used only once!


 Exercise Solutions
Code Magnets:
class Shuffle1 { 
public static void main(String [] args) { 
int x = 3; 
while (x > 0) { 
if (x > 2) { 
System.out.print(“a”); 

x = x - 1; 
System.out.print(“-”); 
if (x == 2) { 
System.out.print(“b c”); 



if (x == 1) { 
System.out.print(“d”); 
x = x - 1; 



}
class Exercise1b { 
public static void main(String [] args) { 
int x = 1; 
while ( x < 10 ) { 
x = x + 1;
A if ( x > 3) { 
System.out.println(“big x”); 


} This will compile and run (no output), but 
} without a line added to the program, it 
would run forever in an infinite ‘while’ loop!
_________________________________________________________
class Foo { 
public static void main(String [] args) { 
int x = 5; 
while ( x > 1 ) { 
x = x - 1; 

Download 17,18 Mb.

Do'stlaringiz bilan baham:
1   ...   13   14   15   16   17   18   19   20   ...   90




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish