Professional Documents
Culture Documents
Starting Out with Java - From Control Structures through Data Structures
Answers to Review Questions
Chapter 9
1. c
2. b
3. a
4. a
5. a
6. c
7. b
8. a
9. d
10. b
11. a
12. c
13. d
14. a
15. False
16. True
17. False
18. True
19. True
20. False
21. True
22. False
23. False
screen, a loop should be used to process each element in the array, so the
statement should read:
for (String s : tokens)
System.out.println(s)
Algorithm Workbench
1. if (Character.toUpperCase(choice) == 'Y')
Or
if (Character.toLowerCase(choice) == 'y')
2. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (str.charAt(i) == ' ')
total++;
}
3. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (Character.isDigit(str.charAt(i)))
total++;
}
4. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (Character.isLowerCase(str.charAt(i)))
total++;
}
if (str2.endsWith(".com"))
status = true;
else
status = false;
return status;
}
9. if (d <= Integer.MAX_VALUE)
i = (int) d;
10. System.out.println(Integer.toBinaryString(i));
System.out.println(Integer.toHexString(i));
System.out.println(Integer.toOctalString(i));
Short Answer
1. This will improve the program’s efficiency by reducing the number of String
objects that must be created and then removed by the garbage collector.
2. When you are tokenizing a string that was entered by the user, and you are using
characters other than whitespaces as delimiters, you will probably want to trim the
string before tokenizing it. Otherwise, if the user enters leading whitespace
characters, they will become part of the first token. Likewise, if the user enters
trailing whitespace characters, they will become part of the last token.
3. Converts a number to a string.
4. Each of the numeric wrapper classes has final static fields named MAX_VALUE
and MIN_VALUE. These fields hold the maximum and minimum values for the
data type.
[112]
[113]
[114]
[115]
Mem. Acc. Lincei Roma (4), iv. 1888, p. 543, etc., and other
preceding memoirs mentioned therein.
[116]
[117]
[118]
[120]
[121]
[122]
[123]
[124]
[125]
[126]
[127]
[128]
[129]
[131]
[132]
[133]
[134]
[135]
[136]
Some writers are of opinion that there are only two thoracic
spiracles in Insects, considering the third as belonging really to the
abdomen. Looking on the point as at present chiefly one of
nomenclature, we make use of the more usual mode of
expression.
[137]
[138]
[139]
It may be worth while to repeat that "joint" means a piece, and is
the equivalent of "link" in a chain.
[140]
[141]
[142]
[143]
[144]
[145]
[146]
[147]
[148]
[149]
Prod. Orth. europ. 1882, p. 27, and Rev. Syst. Orthopt. 1892, p.
15. Unfortunately de Saussure adopts a different nomenclature;
we have preferred Brunner's as being more simple.
[150]
[151]
[152]
[153]
[154]
[155]
Riley, Insect Life, iii. 1891, p. 443, and iv. 1891, p. 119.
[156]
[157]
[158]
[159]
[161]
[162]
[163]
[164]
[165]
Zeitschr. wiss. Zool. xlviii. 1889, p. 89; and Mem. Ac. St. Petersb.
xxxviii. No. 5, 1891.
[166]
[167]
[168]
[169]
[170]
The "black beetle," Stilopyga orientalis, belongs to this tribe, as
does also Periplaneta americana.
[171]
[172]
[173]
[174]
[175]
[176]
The name of the species is not given (Tr. N. Z. Inst. xvi. 1883, p.
114), but it is probably Orthodera ministralis Fab., an Australian
Insect perhaps taken to New Zealand by miners. Cf. Wood-Mason,
Cat. Mantodea, i. 1889, p. 20.
[177]
[178]
[179]
[181]
[182]
[183]
[184]
[185]
[186]
[187]
[188]
[189]
[190]
[192]
[193]
[194]
[195]
[196]
[197]
[198]
SB. Ak. Wien, xci. 1885, p. 361. The nomenclature applied to the
nervures by these authors is not the same as that of Brunner;
according to their view the wing of Phyllium, female, differs more
from the wing of Blatta than it does according to a comparison
made with the nomenclature we adopt.
[199]
[200]
[202]
[203]
[204]
In his recent Insectes fossiles des temps primaires, pp. 373 and
396, M. Brongniart has himself removed this Insect to
Protodonates. We shall again mention it when discussing that
group.
[205]
[206]
[207]
[208]
[209]
This character is evidently erroneous as regards the males of the
genus Phyllium.—D. S.
[210]
[211]
[212]
[213]
[214]
[215]
[216]
[217]
[218]
Denk. Ak. Wien, xxxvi. 1875; Arch. mikr. Anat. xx. and xxi., 1882.
[219]
[221]
[222]
[223]
Bull. Soc. ent. France (6), x. 1890, p. xxxvii., and CR. Ac. Paris,
ex. 1890, p. 657.
[224]
[225]
[226]
[227]
[228]
[229]
[230]
See Redtenbacher, Über Wanderheuschrecken, in Jahresber.
Realschule Budweis, 1893.
[231]
[232]
[233]
[234]
[235]
[236]
[237]
[238]
[239]
[240]
[242]
Bull. Soc. Rouen, 1885, and Insectes fossiles, etc. 1894, p. 439.
[243]
[244]
[245]
[246]
[247]
Arch. f. mikr. Anat. xx. 1882, and xxi. See also von Adelung,
Zeitschr. wiss. Zool. liv. 1892, p. 316.
[248]
The small space above lm left free from dots is, we presume, due
to an omission on the part of Graber's artist, but we have not
thought it right to interfere with his diagram.
[249]
[250]
[252]
Bonnet and Finot, Rev. Sci. Nat. (3) iv. p. 345. The word we have
translated as humming is "bruissement."
[253]
[254]
[255]
[256]
[257]
[258]
[259]
[260]
[262]
[263]
[264]
[265]
[266]
[267]
Mem. Soc. phys. Genève, xxv. 1877, and Biol. Centr. Amer.
Orthoptera, 1894, p. 198.
[268]
[269]
[270]
[271]
[273]
[274]
Op. cit. pp. vii.-xiv. For classification, etc., see also Piaget, Les
Pédiculines. Leyden, 1880.
[275]
[276]
[277]
[278]
[279]
[280]
[281]
[282]
Jena. Zeitschr. Naturw. ix. 1875, pl. xii. See also Stokes in
Science, xxii. 1893, p. 273.
[284]
[285]
[286]
[287]
[288]
[289]
[290]
[291]
[292]
[293]
[295]
Tr. N. York Ac. viii. 1889, pp. 85-114; and ix. 1890, pp. 157-180.
[296]
Camerano, Bull. Soc. ent. Ital. xvii. 1885, p. 89; and Kollmann,
Verh. Ges. Basel, vii. 1883, p. 391.
[297]
[298]
[299]
[300]
[301]
[302]
[303]
[304]
P. Boston Soc. xix. 1878, p. 267; and xx. 1881, p. 121.
[305]
[306]
[307]
[308]
[309]
[310]
[311]
[312]
[313]
[314]