Professional Documents
Culture Documents
https://testbankpack.com/p/test-bank-for-java-how-to-
program-early-objects-10th-edition-deitel-0133807800-
9780133807806/
Solution Manual:
https://testbankpack.com/p/solution-manual-for-java-how-to-
program-early-objects-10th-edition-deitel-0133807800-
9780133807806/
Chapter 2 Introduction to Java Applications
2.2 Q3: Which of the following cannot cause a syntax error to be reported by the Java compiler?
a. Mismatched {}
b. Missing */ in a comment that begins with /*
c. Missing ;
d. An extra blank line.
ANS: d. An extra blank line.
2.2 Q4: Which of the following does not contain a syntax error?
a. System.out.println( 'Hello world!' ):
b. System.out.println( "Hello
world!" );
c. System.out.println( "Hello world!" );
d. System.out.println( Hello world! );
ANS: c. System.out.println( "Hello world!" );
2.2 Q5: Which command compiles the Java source code file Welcome.java?
a. cd Welcome.java
b. javac Welcome.java
c. java Welcome.java
d. compile Welcome.java
ANS: b. javac Welcome.java
2.2 Q6: Which command executes the Java class file Welcome.class?
a. java welcome
b. java Welcome.class
c. java Welcome
d. run Welcome.class
ANS: c. java Welcome (Note that you must use the same capitalization as the class name.)
© Copyright 1992-2015 by Deitel & Associates, Inc. and Pearson Education, Inc.
2.3 Q1: Which is the output of the following statements?
System.out.print( "Hello ");
System.out.println( "World" );
a. Hello World
b. HelloWorld
c. Hello
World
d. World
Hello
ANS: a. Hello World
2.3 Q3: Which of the following statements will print a single line containing
"hello there"?
a. System.out.println( "hello" );
System.out.println( " there" );
b. System.out.println( "hello" , " there" );
c. System.out.println( "hello" );
System.out.print( " there" );
d. System.out.print( "hello" );
System.out.println( " there" );
ANS: d. System.out.print( "hello" );
System.out.println( " there" );
2.3 Q4: Which of the following escape sequences represents a carriage return?
a. \n.
b. \r.
c. \cr.
d. \c.
ANS: b. \r.
2.3 Q5: Which of the following statements would display the phase Java is fun?
a. System.out.println( "hellois fun\rJava " );
b. System.out.println( 'Java is fun' );
c. System.out.println( "\"Java is fun\"" );
d. System.out.println( Java is fun );
ANS: a. System.out.println( "hellois fun\rJava " );
© Copyright 1992-2015 by Deitel & Associates, Inc. and Pearson Education, Inc.
a. System.out.printf( "%2s", "Hello " "World" );
b. System.out.printf( "%s %s", "Hello", "World" );
c. System.out.printf( "%s%s", "Hello, World" );
d. System.out.printf( "s% s%", "Hello", "World" );
ANS: b. System.out.printf( "%s %s", "Hello", "World" );
2.5.2 Q2 The body of each class declaration begins with and ends with .
e. (, ).
f. [, ].
g. {, }.
h. /, \.
ANS: g. {, }.
© Copyright 1992-2015 by Deitel & Associates, Inc. and Pearson Education, Inc.
Section 2.5.3 Declaring and Creating a Scanner to Obtain User
Input from the Keyboard
2.5.3 Q1: Which of the following is a variable declaration statement?
a. int total;
b. import java.util.Scanner;
c. public static void main( String args[] )
d. // first string entered by user
ANS: a. int total;
2.5.3 Q2: A(n) enables a program to read data from the user.
a. printf.
b. import declaration.
c. Scanner.
d. main.
ANS: c. Scanner.
© Copyright 1992-2015 by Deitel & Associates, Inc. and Pearson Education, Inc.
Another document from Scribd.com that is
random and unrelated content:
To make excellent Coffee. See among sick Cookery.
Orgeat.
Put a pound of fine fruit into a China bowl, and pour upon it a
quart of the best white wine vinegar; next day strain the liquor on
a pound of fresh raspberries; and the following day do the same,
but do not squeeze the fruit, only drain the liquor as dry as you
can from it. The last time pass it through a canvass previously wet
with vinegar to prevent waste. Put it into a stonejar, with a pound
of sugar to every pint of juice, broken into large lumps; stir it when
melted, then put the jar into a saucepan of water, or on a hot
hearth, let it simmer, and skim it. When cold, bottle it.
This is one of the most useful preparations that can be kept in a
house, not only as affording the most refreshing beverage, but
being of singular efficacy in complaints of the chest. A large
spoonful or two in a tumbler of water.
N. B. Use no glazed or metal vessel for it.
Note. The fruit, with equal quantity of sugar, makes excellent
raspberry cakes without boiling.
Raspberry wine.
Put two ounces of cream of tartar, and the juice and paring of
two lemons into a stonejar; pour on them seven quarts of boiling
water, stir and cover close. When cold, sweeten with loaf sugar,
and straining it, bottle and cork it tight.
This is a very pleasant liquor, and very wholesome; but from the
latter consideration was at one time drank in such quantities, as to
become injurious. Add, in bottling, half a pint of rum to the whole
quantity.
Excellent Gingerwine.
Put into a very nice boiler ten gallons of water, twelve pounds
and a half of lump sugar, with the whites of six or eight eggs well
beaten and strained; mix all well while cold; when the liquor boils,
skim it well; put in half a pound of common white ginger bruised,
boil it twenty minutes. Have ready the very thin rinds of ten
lemons, and pour the liquor on them; when cool, turn it with two
spoonfuls of yeast; put a quart of the liquor to two ounces of
isinglass shavings, while warm, whisk it well three or four times,
and pour all together into the barrel. Next day stop it up; in three
weeks bottle, and in three months it will be a delicious and
refreshing liquor; and though very cool, perfectly safe.
Another for Gingerwine.
Boil nine quarts of water with six pounds of lump sugar, the
rinds of two or three lemons very thinly pared, with two ounces of
bruised white ginger half an hour; skim. Put three quarters of a
pound of raisins into the cask; when the liquor is lukewarm, tun it
with the juice of two lemons strained, and a spoonful and a half of
yeast. Stir it daily, then put in half a pint of brandy, and half an
ounce of isinglass shavings; stop it up, and bottle it six or seven
weeks. Do not put the lemonpeel in the barrel.
Alderwine.
Take new cyder from the press, mix it with as much honey as
will support an egg, boil gently fifteen minutes, but not in an iron,
brass, or copper pot. Skim it well; when cool, let it be tunned, but
do not quite fill. In March following bottle it, and it will be fit to
drink in six weeks; will be less sweet if kept longer in the cask. You
will have a rich and strong wine, and it will keep well. This will
serve for any culinary purposes which sack, or sweet wine, are
directed for.
Duhamel says, honey is a fine ingredient to assist, and render
palatable, new crabbed austere cider.
Raisinwine, with Cider.
Put two hundred weight of Malaga raisins into a cask, and pour
upon them a hogshead of good sound cider that is not rough. Stir
it well two or three days; stop it, and let it stand six months; then
rack into a cask that it will fill, and put in a gallon of the best
brandy.
If raisinwine be much used, it would answer well to keep a cask
always for it, and bottle off one year’s wine just in time to make
the next, which, allowing the six months of infusion, would make
the wine to be eighteen months old. In cider countries this way is
very economical; and even if not thought strong enough, the
addition of another quarter of a hundred of raisins would be
sufficient, and the wine would still be very cheap.
When the raisins are pressed through a horsehair bag, they will
either produce a very good spirit by distillation, and must be sent
to a chymist who will do it (but if for that purpose, they must be
very little pressed); or they will make excellent vinegar, on which
article see page 116.
The stalks should be picked off for the above, and may be
thrown into any cask of vinegar that is making; being very acid.
Raisinwine, without Cider.
Blanch two ounces of peach and apricot kernels, bruise and put
them into a bottle, and fill nearly up with brandy. Dissolve half a
pound of white sugarcandy in a cup of cold water, and add to the
brandy after it has stood a month on the kernels, and they are
strained off; then filter through paper, and bottle for use.
Raspberry brandy.
Pick fine dry fruit, put into a stonejar, and the jar into a kettle of
water, or on a hot hearth, till the juice will run; strain, and to every
pint add half a pound of sugar, give one boil, and skim it; when
cold, put equal quantities of juice and brandy, shake well, and
bottle. Some people prefer it stronger of the brandy.
Verder, or Milkpunch.
Pare six oranges, and six lemons as thin as you can, grate them
after with sugar to get the flavour. Steep the peels in a bottle of
rum or brandy stopped close twenty four hours. Squeeze the fruit
on a pound and a half of sugar, add to it four quarts of water, and
one of new milk boiling hot; stir the rum into the above, and run it
through a jellybag till perfectly clear. Bottle, and cork close
immediately.
Norfolkpunch.
Pare six lemons and three Seville oranges very thin, squeeze the
juice into a large teapot, put to it two quarts of brandy, one of
white wine, and one of milk, and one pound and a quarter of
sugar. Let it be mixed, and then covered for twenty four hours,
strain through a jellybag till clear; then bottle it.
Orange, or Lemon syrup; a most useful thing to
keep in the house, to take with water, in colds or
fevers.
Squeeze the juice of very good fruit, and boil when strained, a
pint to a pound of sugar, over a very gentle fire; skim it well; when
clear, pour it into a China bowl, and in twenty four hours bottle it
for use.
White Currant shrub.
Strip the fruit, and prepare in a jar as for jelly; strain the juice,
of which put two quarts to one gallon of rum, and two pounds of
lump sugar; strain through a jellybag.
The following pages will contain Cookery for the sick; it being of
more consequence to support those whose bad appetites will not
allow them to take the necessary nourishment, than to stimulate
those that are in health.
It may not be unnecessary to advise that a choice be made of the
things most likely to agree with the patient; that a change be
provided; that some one at least be always ready; that not too
much of those be made at once, which are not likely to keep, as
invalids require variety; and let them succeed each other in a
different form and flavour.
A great Restorative.
Bake two calf’s feet in three pints of water, and new milk, in a
jar close covered, three hours and a half. When cold remove the
fat.
Give a large teacupful the last and first thing. Whatever flavour
is approved, give it by baking in it lemonpeel, cinnamon, or mace.
Add sugar.
Another.
Put the knuckle of a leg or shoulder of veal, with very little meat
to it, an old fowl, and four shankbones of mutton extremely well
soaked and brushed, three blades of mace, ten peppercorns, an
onion, and a large bit of bread, and three quarts of water, into a
stewpot that covers close, and simmer in the slowest manner after
it has boiled up, and been skimmed; or, bake it; strain and take off
the fat. Salt as wanted.
A clear Broth that will keep long.
Take a leg of well fed pork, just as cut up, beat it, and break the
bone. Set it over a gentle fire, with three gallons of water, and
simmer to one. Let half an ounce of mace, and the same of
nutmegs, stew in it. Strain through a line sieve. When cold, take
off the fat. Give a chocolate cup the first and last thing, and at
noon, putting salt to taste.