FOR MORE OF THIS COURSE AND ANY OTHER COURSES, TEST BANKS, FINAL EXAMS, AND SOLUTION MANUALS
CONTACT US
AT WHISPERHILLS@GMAIL.COM
ch02
True/False
Indicate whether the
statement is true or false.
____ 1. If an application contains only one method
that executes, that method is called the main method.
____ 2. Computers deal with two basic types of data -
text and string.
____ 3. A literal numeric constant does not change.
____ 4. A string constant is enclosed within
parentheses.
____ 5. Batch programs can accept data without human
intervention.
____ 6. A variable declaration is a statement that
provides a data type and identifier for a variable.
____ 7. An item’s data type defines what operations
can be performed on the item.
____ 8. If a variable has been initialized, it holds
garbage.
____ 9. A numeric variable can hold digits or letters
of the alphabet.
____ 10. A named constant can be assigned a value only
once.
____ 11. The equals sign is the arithmetic operator.
____ 12. The assignment operator is said to have
right-to-left associativity.
____ 13. Arithmetic operators have right-to-left
associativity.
____ 14. Program comments are a type of external
documentation.
____ 15. As your programming skill increases, the need
for good programming habits decreases.
____ 16. If you choose identifiers with meaningful
names, your program is said to be self-documenting.
____ 17. A noun would be a good choice for a variable
or constant identifier.
____ 18. An adjective would be a good choice of
identifier for a variable that holds status.
____ 19. A temporary variable is not used for input or
output.
____ 20. A prompt is a message that asks the user for
a response.
____ 21. In echoing input, the program tells the user
the desired form of the input data.
____ 22. Three types of program structures are
sequence, selection, and loop.
____ 23. The sequence structure contains a decision
point.
____ 24. Methods may contain one, two, or all three
types of structures.
____ 25. A loop structure does not contain a decision
point.
Multiple Choice
Identify the choice
that best completes the statement or answers the question.
____ 26. A(n) ____ is a named set of statements that
perform some task or group of tasks within an application.
a.
|
method
|
c.
|
object
|
b.
|
class
|
d.
|
flowchart
|
____ 27. A(n) ____ is the name of a programming object
- for example, a class, method, or variable.
a.
|
convention
|
c.
|
keyword
|
b.
|
identifier
|
d.
|
class header
|
____ 28. There will always be only one class ____ for
each class.
a.
|
statement
|
c.
|
header
|
b.
|
method
|
d.
|
footer
|
____ 29. In an interactive program, a ____ enters
data.
a.
|
disk
|
c.
|
user
|
b.
|
database
|
d.
|
graphical user interface
|
____ 30. ____ are memory locations whose contents can
vary or differ over time.
a.
|
Constants
|
c.
|
Strings
|
b.
|
Variables
|
d.
|
Magic numbers
|
____ 31. ____ constants do not have identifiers like
variables do.
a.
|
Alphabetic
|
c.
|
Unnamed
|
b.
|
Named
|
d.
|
Uncertain
|
____ 32. String values are also called ____ values.
a.
|
unnamed
|
c.
|
alphabetic
|
b.
|
digit
|
d.
|
alphanumeric
|
____ 33. Which of the following is correct if the data
type of inventoryItem is string?
a.
|
inventoryItem = 3
|
c.
|
inventoryItem = -9
|
b.
|
inventoryItem = ”printer”
|
d.
|
inventoryItem = (printer)
|
____ 34. Which of the following is correct if the data
type for weight is num?
a.
|
weight = 2.75
|
c.
|
weight = (2.75)
|
b.
|
weight = “2.75”
|
d.
|
weight = “heavy”
|
____ 35. The convention used in this book for named
constants is ____ characters ____ underscores to separate words.
a.
|
uppercase, with
|
c.
|
lowercase, with
|
b.
|
uppercase, without
|
d.
|
lowercase, without
|
____ 36. A(n) ____ statement stores the value of the
right hand side of the expression in the memory location of the left hand side.
a.
|
construct
|
c.
|
equals
|
b.
|
arithmetic
|
d.
|
assignment
|
____ 37. According to the rules of precedence, ____
has higher precedence than addition.
a.
|
multiplication
|
c.
|
the equals sign
|
b.
|
subtraction
|
d.
|
assignment
|
____ 38. What operator has the lowest precedence?
a.
|
+
|
c.
|
*
|
b.
|
/
|
d.
|
=
|
____ 39. In the following statement, which arithmetic
operation is performed first?
answer = a + b +c * d / e - f
a.
|
e-f
|
c.
|
c*d
|
b.
|
a+b
|
d.
|
d/e
|
____ 40. In the following statement, which operation
is done third?
answer = a + b + c * d / e - f
a.
|
a+b
|
c.
|
e-f
|
b.
|
b+c
|
d.
|
d/e
|
____ 41. What is an equivalent way to write the
following statement?
answer = a + b + c * d / e - f
a.
|
answer = a+b+(c*d)/(e-f)
|
c.
|
answer = a+b+(c*d/e-f)
|
b.
|
answer = a+b+(c*d)/e-f
|
d.
|
answer = a+b+c*(d/e)-f
|
____ 42. What is an example of a good programming
practice?
a.
|
using program comments
|
c.
|
accepting user input without echoing
|
b.
|
using frequent abbreviations
|
d.
|
creating your own conventions
|
____ 43. Which of the following would be the best
choice of identifier for a method that calculates an employee’s pay?
a.
|
paycheck
|
c.
|
determinePay
|
b.
|
accuratePaycheck
|
d.
|
taxWithholding
|
____ 44. What is one drawback to including program
comments?
a.
|
They take up too much memory.
|
c.
|
You cannot use abbreviations.
|
b.
|
They must be kept current.
|
d.
|
They make a program difficult to read.
|
____ 45. A ____ dictionary is a list of every variable
name used in a program.
a.
|
naming
|
c.
|
constant
|
b.
|
string
|
d.
|
data
|
____ 46. Most modern programming languages are ____,
meaning that you can arrange your lines of code as you see fit.
a.
|
structured
|
c.
|
formatted
|
b.
|
columnar
|
d.
|
free-form
|
____ 47. What is an advantage of using the practice of
echoing input?
a.
|
The program is shorter.
|
b.
|
Memory usage is lower.
|
c.
|
There is less chance of syntax errors.
|
d.
|
The user is more likely to catch input
errors.
|
____ 48. With a ____ structure, you perform an action
or event, and then you perform the next action, in order.
a.
|
loop
|
c.
|
selection
|
b.
|
decision
|
d.
|
sequence
|
____ 49. Sequences never include ____.
a.
|
terminations
|
c.
|
decisions
|
b.
|
tasks
|
d.
|
steps
|
____ 50. In the ____ structure, instructions repeat
based on a decision.
a.
|
sequence
|
c.
|
loop
|
b.
|
selection
|
d.
|
flowchart
|
ch02
Answer
Section
TRUE/FALSE
1. ANS: T PTS: 1 REF: 36
2. ANS: F PTS: 1 REF: 40
3. ANS: T PTS: 1 REF: 40
4. ANS: F PTS: 1 REF: 40
5. ANS: T PTS: 1 REF: 40
6. ANS: T PTS: 1 REF: 41
7. ANS: T PTS: 1 REF: 41
8. ANS: F PTS: 1 REF: 42
9. ANS: F PTS: 1 REF: 42
10. ANS: T PTS: 1 REF: 43
11. ANS: F PTS: 1 REF: 44
12. ANS: T PTS: 1 REF: 45
13. ANS: F PTS: 1 REF: 47
14. ANS: F PTS: 1 REF: 48
15. ANS: F PTS: 1 REF: 48
16. ANS: T PTS: 1 REF: 49
17. ANS: T PTS: 1 REF: 49
18. ANS: F PTS: 1 REF: 50
19. ANS: T PTS: 1 REF: 51
20. ANS: T PTS: 1 REF: 52
21. ANS: F PTS: 1 REF: 54
22. ANS: T PTS: 1 REF: 55
23. ANS: F PTS: 1 REF: 55
24. ANS: T PTS: 1 REF: 55
25. ANS: F PTS: 1 REF: 56
MULTIPLE CHOICE
26. ANS: A PTS: 1 REF: 36
27. ANS: B PTS: 1 REF: 36
28. ANS: C PTS: 1 REF: 37
29. ANS: C PTS: 1 REF: 39
30. ANS: B PTS: 1 REF: 40
31. ANS: C PTS: 1 REF: 40
32. ANS: D PTS: 1 REF: 40
33. ANS: B PTS: 1 REF: 43
34. ANS: A PTS: 1 REF: 43
35. ANS: A PTS: 1 REF: 44
36. ANS: D PTS: 1 REF: 44
37. ANS: A PTS: 1 REF: 47
38. ANS: D PTS: 1 REF: 47
39. ANS: C PTS: 1 REF: 47
40. ANS: A PTS: 1 REF: 47
41. ANS: B PTS: 1 REF: 47
42. ANS: A PTS: 1 REF: 48
43. ANS: C PTS: 1 REF: 49
44. ANS: B PTS: 1 REF: 49
45. ANS: D PTS: 1 REF: 50
46. ANS: D PTS: 1 REF: 51
47. ANS: D PTS: 1 REF: 54
48. ANS: D PTS: 1 REF: 55
49. ANS: C PTS: 1 REF: 55
50. ANS: C PTS: 1 REF: 56
No comments:
Post a Comment