Complete Answer Guide for Test Bank for Intro to Java Programming, Comp Version, 10/E 10th Edition : 0133813460
Complete Answer Guide for Test Bank for Intro to Java Programming, Comp Version, 10/E 10th Edition : 0133813460
https://testbankmall.com/product/solution-manual-for-intro-to-java-
programming-comp-version-10-e-10th-edition-0133813460/
testbankmall.com
https://testbankmall.com/product/introduction-to-java-programming-
comprehensive-version-10th-edition-liang-test-bank/
testbankmall.com
https://testbankmall.com/product/test-bank-for-introduction-to-java-
programming-comprehensive-version-9-e-9th-edition-0133050572/
testbankmall.com
https://testbankmall.com/product/test-bank-for-principles-of-life-2nd-
edition-hillis/
testbankmall.com
Test Bank for Precalculus, 11th Edition, Sullivan
https://testbankmall.com/product/test-bank-for-precalculus-11th-
edition-sullivan/
testbankmall.com
https://testbankmall.com/product/understanding-nutrition-whitney-13th-
edition-solutions-manual/
testbankmall.com
https://testbankmall.com/product/test-bank-for-essentials-of-
economics-the-mcgraw-hill-series-economics-9th-edition-bradley-
schiller/
testbankmall.com
Page 2
chapter2.txt
double number1 = input.nextDouble();
double number2 = input.nextDouble();
double number3 = input.nextDouble();
// Compute average
double average = (number1 + number2 + number3) / 3;
// Display result
System.out.println(average);
}
}
a. 1.0
b. 2.0
c. 3.0
d. 4.0
Key:b
#
4. What is the exact output of the following code?
a. 3.53.5
b. 3.5 3.5
c. area3.5
d. area 3.5
Key:c
#
Section 2.4 Identifiers
4. Every letter in a Java keyword is in lowercase?
a. true
b. false
Key:a
#
5. Which of the following is a valid identifier?
a. $343
b. class
c. 9X
d. 8+9
e. radius
Key:ae
Page 3
chapter2.txt
Section 2.5 Variables
6. Which of the following are correct names for variables according to Java
naming conventions?
a. radius
b. Radius
c. RADIUS
d. findArea
e. FindArea
Key:ad
#
7. Which of the following are correct ways to declare variables?
a. int length; int width;
b. int length, width;
c. int length; width;
d. int length, int width;
Key:ab
#
Section 2.6 Assignment Statements and Assignment Expressions
8. is the Java assignment operator.
a. ==
b. :=
c. =
d. =:
Key:c
#
9. To assign a value 1 to variable x, you write
a. 1 = x;
b. x = 1;
c. x := 1;
d. 1 := x;
e. x == 1;
Key:b
#
10. Which of the following assignment statements is incorrect?
a. i = j = k = 1;
b. i = 1; j = 1; k = 1;
c. i = 1 = j = 1 = k = 1;
d. i == j == k == 1;
Key:cd
#
Section 2.7 Named Constants
11. To declare a constant MAX_LENGTH inside a method with value 99.98, you write
a. final MAX_LENGTH = 99.98;
Page 4
chapter2.txt
b. final float MAX_LENGTH = 99.98;
c. double MAX_LENGTH = 99.98;
d. final double MAX_LENGTH = 99.98;
Key:d
#
12. Which of the following is a constant, according to Java naming conventions?
a. MAX_VALUE
b. Test
c. read
d. ReadInt
e. COUNT
Key:ae
#
13. To improve readability and maintainability, you should declare
instead of using literal values such as 3.14159.
a. variables
b. methods
c. constants
d. classes
Key:c
#
Section 2.8 Naming Conventions
60. According to Java naming convention, which of the following names can be
variables?
a. FindArea
b. findArea
c. totalLength
d. TOTAL_LENGTH
e. class
Key:bc
#
Section 2.9 Numeric Data Types and Operations
14. Which of these data types requires the most amount of memory?
a. long
b. int
c. short
d. byte
Key:a
#
34. If a number is too large to be stored in a variable of the float type, it
.
a. causes overflow
b. causes underflow
Page 5
chapter2.txt
c. causes no error
d. cannot happen in Java
Key:a
#
15. Analyze the following code:
#
16. What is the result of 45 / 4?
a. 10
b. 11
c. 11.25
d. 12
Key:b 45 / 4 is an integer division, which results in 11
#
18. Which of the following expression results in a value 1?
a. 2 % 1
b. 15 % 4
c. 25 % 5
d. 37 % 6
Key:d 2 % 1 is 0, 15 % 4 is 3, 25 % 5 is 0, and 37 % 6 is 1
#
19. 25 % 1 is
a. 1
b. 2
c. 3
d. 4
Page 6
chapter2.txt
e. 0
Key:e
#
20. -25 % 5 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:e
#
21. 24 % 5 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:d
#
22. -24 % 5 is
a. -1
b. -2
c. -3
d. -4
e. 0
Key:d
#
23. -24 % -5 is
a. 3
b. -3
c. 4
d. -4
e. 0
Key:d
#
30. Math.pow(2, 3) returns .
a. 9
b. 8
c. 9.0
d. 8.0
Key:d It returns a double value 8.0.
Page 7
chapter2.txt
30. Math.pow(4, 1 / 2) returns .
a. 2
b. 2.0
c. 0
d. 1.0
e. 1
Key:d Note that 1 / 2 is 0.
#
30. Math.pow(4, 1.0 / 2) returns .
a. 2
b. 2.0
c. 0
d. 1.0
e. 1
Key:b Note that the pow method returns a double value, not an integer.
#
31. The method returns a raised to the power of b.
a. Math.power(a, b)
b. Math.exponent(a, b)
c. Math.pow(a, b)
d. Math.pow(b, a)
Key:c
#
Section 2.10 Numeric Literals
15. To declare an int variable number with initial value 2, you write
a. int number = 2L;
b. int number = 2l;
c. int number = 2;
d. int number = 2.0;
Key:c
#
32. Analyze the following code.
Page 8
chapter2.txt
digit. An octal digit is 0, 1, 2, 3, 4, 5, 6, or 7.
#
15. Which of the following are the same as 1545.534?
a. 1.545534e+3
b. 0.1545534e+4
c. 1545534.0e-3
d. 154553.4e-2
Key:abcd
#
Section 2.11 Evaluating Expressions and Operator Precedence
24. The expression 4 + 20 / (3 - 1) * 2 is evaluated to
a. 4
b. 20
c. 24
d. 9
e. 25
Key:c
#
Section 2.12 Case Study: Displaying the Current Time
58. The System.currentTimeMillis() returns .
a. the current time.
b. the current time in milliseconds.
c. the current time in milliseconds since midnight.
d. the current time in milliseconds since midnight, January 1, 1970.
e. the current time in milliseconds since midnight, January 1, 1970 GMT (the
Unix time).
Key:e
#
24. To obtain the current second, use .
a. System.currentTimeMillis() % 3600
b. System.currentTimeMillis() % 60
c. System.currentTimeMillis() / 1000 % 60
d. System.currentTimeMillis() / 1000 / 60 % 60
e. System.currentTimeMillis() / 1000 / 60 / 60 % 24
Key:c
#
24. To obtain the current minute, use .
a. System.currentTimeMillis() % 3600
b. System.currentTimeMillis() % 60
c. System.currentTimeMillis() / 1000 % 60
d. System.currentTimeMillis() / 1000 / 60 % 60
e. System.currentTimeMillis() / 1000 / 60 / 60 % 24
Key:d
Page 9
chapter2.txt
#
24. To obtain the current hour in UTC, use _.
a. System.currentTimeMillis() % 3600
b. System.currentTimeMillis() % 60
c. System.currentTimeMillis() / 1000 % 60
d. System.currentTimeMillis() / 1000 / 60 % 60
e. System.currentTimeMillis() / 1000 / 60 / 60 % 24
Key:e
#
Section 2.13 Augmented Assignment Operators
24. To add a value 1 to variable x, you write
a. 1 + x = x;
b. x += 1;
c. x := 1;
d. x = x + 1;
e. x = 1 + x;
Key:bde
#
25. To add number to sum, you write (Note: Java is case-sensitive)
a. number += sum;
b. number = sum + number;
c. sum = Number + sum;
d. sum += number;
e. sum = sum + number;
Key:de
#
26. Suppose x is 1. What is x after x += 2?
a. 0
b. 1
c. 2
d. 3
e. 4
Key:d
#
27. Suppose x is 1. What is x after x -= 1?
a. 0
b. 1
c. 2
d. -1
e. -2
Key:a
Page 10
chapter2.txt
28. What is x after the following statements?
int x = 2;
int y = 1;
x *= y + 1;
a. x is 1.
b. x is 2.
c. x is 3.
d. x is 4.
Key:d
#
29. What is x after the following statements?
int x = 1;
x *= x + 1;
a. x is 1.
b. x is 2.
c. x is 3.
d. x is 4.
Key:b
#
29. Which of the following statements are the same?
(A) x -= x + 4
(B) x = x + 4 - x
(C) x = x - (x + 4)
#
Section 2.14 Increment and Decrement Operators
21. Are the following four statements equivalent?
number += 1;
number = number + 1;
number++;
++number;
a. Yes
b. No
Key:a
Page 11
Visit https://testbankmall.com
now to explore a rich
collection of testbank,
solution manual and enjoy
exciting offers!
chapter2.txt
#
34. What is i printed?
public class Test {
public static void main(String[] args) {
int j = 0;
int i = ++j + j * 5;
#
35. What is i printed in the following code?
#
36. What is y displayed in the following code?
Page 12
chapter2.txt
c. y is 3.
d. y is 4.
Key:c When evaluating x++ + x, x++ is evaluated first, which does two things: 1.
returns 1 since it is post-increment. x becomes 2. Therefore y is 1 + 2.
#
37. What is y displayed?
#
Section 2.15 Numeric Type Conversions
38. To assign a double variable d to a float variable x, you write
a. x = (long)d
b. x = (int)d;
c. x = d;
d. x = (float)d;
Key:d
#
17. Which of the following expressions will yield 0.5?
a. 1 / 2
b. 1.0 / 2
c. (double) (1 / 2)
d. (double) 1 / 2
e. 1 / 2.0
Key:bde 1 / 2 is an integer division, which results in 0.
#
39. What is the printout of the following code:
double x = 5.5;
int y = (int)x;
System.out.println("x is " + x + " and y is " + y);
a. x is 5 and y is 6
b. x is 6.0 and y is 6.0
Page 13
chapter2.txt
c. x is 6 and y is 6
d. x is 5.5 and y is 5
e. x is 5.5 and y is 5.0
Key:d The value is x is not changed after the casting.
#
40. Which of the following assignment statements is illegal?
a. float f = -34;
b. int t = 23;
c. short s = 10;
d. int t = (int)false;
e. int t = 4.5;
Key:de
#
41. What is the value of (double)5/2?
a. 2
b. 2.5
c. 3
d. 2.0
e. 3.0
Key:b
#
42. What is the value of (double)(5/2)?
a. 2
b. 2.5
c. 3
d. 2.0
e. 3.0
Key:d
#
43. Which of the following expression results in 45.37?
a. (int)(45.378 * 100) / 100
b. (int)(45.378 * 100) / 100.0
c. (int)(45.378 * 100 / 100)
d. (int)(45.378) * 100 / 100.0
Key:b
#
43. The expression (int)(76.0252175 * 100) / 100 evaluates to .
a. 76.02
b. 76
c. 76.0252175
d. 76.03
Key:b In order to obtain 76.02, you have divide 100.0.
Page 14
chapter2.txt
#
44. If you attempt to add an int, a byte, a long, and a double, the result will
be a value.
a. byte
b. int
c. long
d. double
Key:d
#
Section 2.16 Software Life Cycle
1. is a formal process that seeks to understand the problem and
system’s input and output. When you do analysis, it helps to identify what the
output is first, and then figure out what input data you need in order to produce
the output.
a. Requirements specification
b. Analysis
c. Design
d. Implementation
e. Testing
Key:b
#
0. Any assignment statement can be used as an assignment expression.
a. true
b. false
Key:a
#
1. You can define a constant twice in a block.
a. true
b. false
Key:b
#
44. are valid Java identifiers.
a. $Java
b. _RE4
Page 15
chapter2.txt
c. 3ere
d. 4+4
e. int
Key:ab
#
2. You can define a variable twice in a block.
a. true
b. false
Key:b
#
3. The value of a variable can be changed.
a. true
b. false
Key:a
#
4. The result of an integer division is the integer part of the division; the
fraction part is truncated.
a. true
b. false
Key:a
#
5. You can always assign a value of int type to a variable of long type without
loss of information.
a. true
b. false
Key:a
#
6. You can always assign a value of long type to a variable of int type without
loss of precision.
a. true
b. false
Key:b
#
13. A variable may be assigned a value only once in the program.
a. true
b. false
Key:b
#
14. You can change the value of a constant.
a. true
b. false
Page 16
chapter2.txt
Key:b
#
2. To declare a constant PI, you write
a. final static PI = 3.14159;
b. final float PI = 3.14159;
c. static double PI = 3.14159;
d. final double PI = 3.14159;
Key:d
#
3. To declare an int variable x with initial value 200, you write
a. int x = 200L;
b. int x = 200l;
c. int x = 200;
d. int x = 200.0;
Key:c
#
4. To assign a double variable d to an int variable x, you write
a. x = (long)d
b. x = (int)d;
c. x = d;
d. x = (float)d;
Key:b
#
8. Which of the following is a constant, according to Java naming conventions?
a. MAX_VALUE
b. Test
c. read
d. ReadInt
Key:a
#
9. Which of the following assignment statements is illegal?
a. float f = -34;
b. int t = 23;
c. short s = 10;
d. float f = 34.0;
Key:d
#
10. A Java statement ends with a .
a. comma (,)
b. semicolon (;)
c. period (.)
d. closing brace
Page 17
chapter2.txt
Key:b
#
11. The assignment operator in Java is .
a. :=
b. =
c. = =
d. <-
Key:b
#
12. Which of these data types requires the least amount of memory?
a. float
b. double
c. short
d. byte
Key:d
#
13. Which of the following operators has the highest precedence?
a. casting
b. +
c. *
d. /
Key:a
#
17. If you attempt to add an int, a byte, a long, and a float, the result will
be a value.
a. float
b. int
c. long
d. double
Key:a
#
18. If a program compiles fine, but it terminates abnormally at runtime, then
the program suffers .
a. a syntax error
b. a runtime error
c. a logic error
Key:b
#
24. What is 1 % 2?
a. 0
b. 1
c. 2
Page 18
chapter2.txt
Key:b
#
26. What is the printout of the following code:
double x = 10.1;
int y = (int)x;
System.out.println("x is " + x + " and y is " + y);
a. x is 10 and y is 10
b. x is 10.0 and y is 10.0
c. x is 11 and y is 11
d. x is 10.1 and y is 10
e. x is 10.1 and y is 10.0
Key:d
#
32. The compiler checks .
a. syntax errors
b. logical errors
c. runtime errors
Key:a
#
33. You can cast a double value to _.
a. byte
b. short
c. int
d. long
e. float
Key:abcde
#
34. The keyword must be used to declare a constant.
a. const
b. final
c. static
d. double
e. int
Key:b
#
37. pow is a method in the class.
a. Integer
b. Double
c. Math
d. System
Key:c
Page 19
chapter2.txt
#
38. currentTimeMills is a method in the class.
a. Integer
b. Double
c. Math
d. System
Key:d
#
39. 5 % 1 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:e
#
40. 5 % 2 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:a
#
41. 5 % 3 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:b
#
42. 5 % 4 is
a. 1
b. 2
c. 3
d. 4
e. 0
Key:a
#
43. 5 % 5 is
a. 1
Page 20
chapter2.txt
b. 2
c. 3
d. 4
e. 0
Key:e
#
43. -5 % 5 is
a. -1
b. -2
c. -3
d. -4
e. 0
Key:e
#
43. -15 % 4 is
a. -1
b. -2
c. -3
d. -4
e. 0
Key:c
#
43. -15 % -4 is
a. -1
b. -2
c. -3
d. -4
e. 0
Key:c
#
43. A variable must be declared before it can be used.
a. True
b. False
Key:a
#
43. A constant can be defined using using the final keyword.
a. True
b. False
Key:a
#
43. Which of the following are not valid assignment statements?
a. x = 55;
Page 21
Visit https://testbankmall.com
now to explore a rich
collection of testbank,
solution manual and enjoy
exciting offers!
Other documents randomly have
different content
Fig. 100. Norfolk Wherry.
After the squaresail had for so many centuries held sway among
the earliest dwellers of the earth, the lateen began stealthily to
assert itself as we saw in the first chapters. Although Holland set the
example in the sixteenth century of cutting up the lateen shape into
the cutter rig, yet in the Mediterranean, along the East Coast of
Africa and in the Indian Ocean generally, the lateen has refused to
be made obsolete. The illustration in Fig. 101 represents a Bombay
yacht of the second half of
the nineteenth century
rigged with a couple of
lateens, and masts that
rake forward at a
considerable angle. Every
tourist to Egypt is familiar
with the picturesque
lateens and lofty yards of
which Fig. 102, showing a
fleet of these with a small
Sibbick rater in between,
affords a study in contrast
between the conservative
East and the progressive
West. The sketch was
made at Suez. The felucca
in Fig. 103 is a well-known
lateen type in the
Mediterranean, with her
white and green, her
square stern and single
deck. The sketch here Fig. 103. Mediterranean Felucca.
shown has been made From the model in the South Kensington
from a charming little Museum.
model in the South
Kensington Museum, and
represents one of the familiar two-masters seen off the Spanish
coast. The tack and sheets and rigging are shown so clearly that we
need not stop to indicate them. In old paintings and prints we see
that the felucca type in the Mediterranean developed into vessels of
considerable tonnage with three masts. The Venetians and Greeks
and Genoese, as well as the piratical Moors and the other
Mediterranean inhabitants, used them both as cargo carriers and
ships of war. They are in fact the lineal descendants of the ancient
galleys. Further modifications include the addition of a jib, though
the Southerner has not followed the universal Northern practice of
transforming his lateen into a mainsail. Sometimes we find old prints
showing a felucca with the addition also of a mizzen spritsail similar
to that on the modern barge. The French signified by the word
brigantin a two-masted lateen-rigged galley with oars as auxiliary.
But there came into use that compromise between lateen and
squaresail that in Northern Europe we have seen to exist between
the pure fore-and-after and the square-rigger. Thus, for instance,
one finds ships rigged with a large lateen on the foremast, the
mainmast being square-rigged with mainsail, topsail and t’gallant,
while the mizzen has a lateen with square topsail. The reader who
wishes to see the different varieties of lateen and lateen-plus-square
rig is referred to Mr. Warington Smyth’s interesting volume “Mast and
Sail,” while for details as to design and rigging he will find some
valuable information in Admiral Paris’ “Souvenirs de Marine.”
Every one who has cruised down Channel is familiar with the
French Chasse-Marée, a curious figure on the sea-line, with her lug-
sails and three crazy-looking masts. Over the mainmast she sets a
square topsail, while forward she carries a long bowsprit with a small
jib, the latter being in shape more of an equal-sided triangle than
the modern English jib, while the French lug-sail is sheeted very
high, as will be seen from the sketch (see Fig. 107).
Fig. 107. French “Chasse-Marée.”
At one time Norfolk was famous for its beach yawls. Those who
have visited Great Yarmouth will have noticed these very large open
boats painted white with (if I remember correctly) a riband of green
running along the gunwale. Double-ended, they are now usually
rigged cutter fashion and used as pleasure boats. Clinker-built, they
have a very fine entrance and a clean run, and sometimes measure
50 feet in length and 10 feet beam. They used to carry three lug-
sails and jib owing to French influence. In the days when sailing
ships were more frequent than to-day, Yarmouth Roads were usually
a crowded anchorage, and these yawls would be launched almost
every day during the winter to assist a vessel that had been picked
up by the shoals. Nowadays one still sees them used for bringing
pilots ashore, but it is at the Yarmouth and Lowestoft regattas that
one is able to realise alike their enormous speed on a reach and the
dexterity of each crew, numbering about twenty. The three-masted
lug rig of olden days has now given way to a two-master with a
dipping lug for the main and standing mizzen, besides a small jib
forward.
Fig. 108. Scotch “Zulu.”
Until about 1860 the Scotch fishing boat was entirely influenced by
Norway, and even to-day no one could deny that this influence is
altogether wanting. But at last the fisherman began to seek the
herring further out to sea, and so a bolder, decked ship was evolved,
and clinker-build gave way to carvel, and the design was given finer
lines and greater draught. I have watched a fleet of such vessels as
in Fig. 108 running into Scarborough Bay with an onshore breeze in
the soft light of a September afternoon, with their yacht-like lines
and their fine massive hulls suggesting an ideal combination of
strength and beauty. Most of these large “Zulus,” as they are called,
carry steam capstans for getting in the heavy nets, hoisting sail and
warping into harbour. Within the last few years they have been fitted
with steering wheels instead of helms. They are good boats to
windward, and are able to carry their enormous lugs longer than
most vessels could keep aloft a similar area of sail.
After the success of America a change was made in the old type of
yacht. The Alarm which had been built in 1834 as a cutter of 193
tons, was in 1852, consequent on America’s victory, lengthened 20
feet by the bow and converted into a schooner of 248 tons. The
illustration in Fig. 113, which is reproduced by kind permission of the
Royal Victoria Yacht Club, Ryde, shows the Alarm after she had been
rigged after the manner of America with one headsail, having its foot
laced to a boom, with a foresail having gaff but no boom, and with a
mainsail with both gaff and boom. As here seen she justified the
alterations made in her and remained for many years the fastest
schooner of the fleet. But not only in rig and design did America
make a complete revolution. Hitherto our sails had been mere wind-
bags, but the America had her sails made so as to lace to the spars,
while ours had been loose-footed on the boom. The American
yacht’s canvas thus set flatter and she could hold a better wind than
our craft. Henceforth English sail-makers adopted the new idea.
Schooners at least took to the new shape at once but the cutters
were a little time before they followed the lead thus given to them.
It was to America, therefore, that the last existing relic of
mediævalism in British ships was banished off the face of the waters
for ever.
During the ’seventies and till the ’eighties, the tendency was to
build yachts whose dimensions were still deeper, narrower and
longer. Beam was thought deserving of little consideration and
altogether undervalued until the year 1886, when an entire change
of feeling came. The illustration in Fig. 115 shows the wonderful old
Bloodhound. She was built by Mr. William Fife of Fairlie in 1874 for
the Marquis of Ailsa and was one of the famous class of 40-tonners
which flourished during the ’seventies and into the ’eighties. During
the six years she belonged to her first owner she won about £2500
worth of prizes, and afterwards changed hands. Last year, however,
Lord Ailsa re-purchased her, and with new sails the old ship showed
that her marvellous turn of speed had not deserted her. She did
remarkably well during Cowes week until she had the misfortune to
be sunk in collision with L’Esperance, and lay for some time at the
entrance to Cowes fairway, a sad sight, with her masts showing
above water and her crew at work salving what they could. She has
since been raised, and this year is again racing with surprising
success.
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.
testbankmall.com