Chapter 2: Applications and Data

TRUE/FALSE

	1.	Computers deal with two basic types of data - text and string.

ANS:	F	PTS:	1	REF:	36

	2.	A literal numeric constant does not change.

ANS:	T	PTS:	1	REF:	36

	3.	An item’s data type defines what operations can be performed on the item.

ANS:	T	PTS:	1	REF:	37

	4.	A named constant can be assigned a value multiple times.

ANS:	F	PTS:	1	REF:	39

	5.	The assignment operator is said to have right-to-left associativity.

ANS:	T	PTS:	1	REF:	41

	6.	A noun would be a good choice for a variable or constant identifier.

ANS:	T	PTS:	1	REF:	45

	7.	An adjective would be a good choice of identifier for a variable that holds status.

ANS:	F	PTS:	1	REF:	46

	8.	In echoing input, the program tells the user the desired form of the input data.

ANS:	F	PTS:	1	REF:	50

	9.	Three types of program structures are sequence, selection, and loop.

ANS:	T	PTS:	1	REF:	51

	10.	A loop structure does not contain a decision point.

ANS:	F	PTS:	1	REF:	51

MULTIPLE CHOICE

	1.	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	

ANS:	A	PTS:	1	REF:	32

	2.	There will always be only one class ____ for each class.
a.	statement	c.	header	
b.	method	d.	footer	

ANS:	C	PTS:	1	REF:	33

	3.	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	

ANS:	B	PTS:	1	REF:	33

	4.	In an interactive program, a ____ enters data.
a.	disk	c.	user	
b.	database	d.	graphical user interface	

ANS:	C	PTS:	1	REF:	35

	5.	____ constants do not have identifiers like variables do.
a.	Alphabetic	c.	Unnamed	
b.	Named	d.	Uncertain	

ANS:	C	PTS:	1	REF:	36

	6.	String values are also called ____ values.
a.	unnamed	c.	alphabetic	
b.	digit	d.	alphanumeric	

ANS:	D	PTS:	1	REF:	36

	7.	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)	

ANS:	B	PTS:	1	REF:	39

	8.	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”	

ANS:	A	PTS:	1	REF:	39

	9.	You can use named constants to make your programs easier to understand by eliminating ____.
a.	constants	c.	strings	
b.	variables	d.	magic numbers	

ANS:	D	PTS:	1	REF:	40

	10.	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	

ANS:	A	PTS:	1	REF:	40

	11.	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	

ANS:	D	PTS:	1	REF:	41

	12.	The ___ dictate the order in which operations in the same statement are carried out.
a.	sequence structures	c.	decision points	
b.	named constants	d.	order of operations	

ANS:	D	PTS:	1	REF:	42

	13.	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	

ANS:	C	PTS:	1	REF:	43

	14.	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	

ANS:	A	PTS:	1	REF:	43

	15.	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	

ANS:	B	PTS:	1	REF:	43

	16.	What operator has the lowest precedence?
a.	+	c.	*	
b.	/	d.	=	

ANS:	D	PTS:	1	REF:	44

	17.	According to the rules of precedence, ____ has higher precedence than addition.
a.	multiplication	c.	the equals sign	
b.	subtraction	d.	assignment	

ANS:	A	PTS:	1	REF:	44

	18.	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.	

ANS:	B	PTS:	1	REF:	45

	19.	Programmers refer to programs that contain meaningful names as ____.
a.	external documentation	c.	internally consistent	
b.	self-documenting	d.	applications	

ANS:	B	PTS:	1	REF:	45

	20.	A ____ dictionary is a list of every variable name used in a program.
a.	naming	c.	constant	
b.	string	d.	data	

ANS:	D	PTS:	1	REF:	46

	21.	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	

ANS:	D	PTS:	1	REF:	47

	22.	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.	

ANS:	D	PTS:	1	REF:	50

	23.	Sequences never include ____.
a.	terminations	c.	decisions	
b.	tasks	d.	steps	

ANS:	C	PTS:	1	REF:	51

	24.	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	

ANS:	D	PTS:	1	REF:	51

	25.	In the ____ structure, instructions repeat based on a decision.
a.	sequence	c.	loop	
b.	selection	d.	flowchart	

ANS:	C	PTS:	1	REF:	52

COMPLETION

	1.	If an application contains only one method that executes, that method is called the ____________________ method.

ANS:	main

PTS:	1	REF:	32

	2.	____________________ programs can accept data without human intervention.

ANS:	
Batch
batch

PTS:	1	REF:	35-36

	3.	A  ____________________ constant is enclosed within quotation marks.

ANS:	string

PTS:	1	REF:	36

	4.	____________________ are named memory locations with contents that can change.

ANS:	
Variables
variables

PTS:	1	REF:	36

	5.	A variable ____________________ is a statement that provides a data type and identifier for a variable.

ANS:	declaration

PTS:	1	REF:	37

	6.	Until a variable is initialized, it holds an unknown value referred to as ____________________.

ANS:	garbage

PTS:	1	REF:	38

	7.	An operand that can be used to the right of an operator is a(n) ____________________.

ANS:	rvalue

PTS:	1	REF:	41

	8.	The equal sign is the ____________________ operator.

ANS:	assignment

PTS:	1	REF:	41

	9.	Arithmetic operators have ____________________ associativity.

ANS:	
left-to-right
left to right

PTS:	1	REF:	43

	10.	The ____________________ operator has the lowest precedence.

ANS:	assignment

PTS:	1	REF:	44

	11.	Program comments are a type of ____________________ documentation.

ANS:	internal

PTS:	1	REF:	44-45

	12.	A(n) ____________________ variable is not used for input or output.

ANS:	temporary

PTS:	1	REF:	47

	13.	A(n) ____________________ is a message that asks the user for a response.

ANS:	prompt

PTS:	1	REF:	48

	14.	A(n) ____________________ is a basic unit of programming logic.

ANS:	structure

PTS:	1	REF:	51

	15.	In a(n) ____________________ structure, one of two branches of logic is followed based on a decision.

ANS:	selection

PTS:	1	REF:	52