• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

D278 Practice Exam 2 Questions with Verified Correct Answers

Document preview thumbnail
Preview 2 out of 7 pages

D278 Practice Exam 2 Questions with Verified Correct Answers

Content preview

D278 Practice Exam 2 Questions with Verified

Correct Answers

A vending machine starts with 7 sodas. After restocking, the code runs: x = 7; x = x + 3. What is
the final value of x?

10

A warehouse tracks pallets. The code runs: y = 4; z = y * 2; y = y + z. What is the final value of
y?

12

A programmer names a variable "3rdPlace" to store a contestant's ranking. Is "3rdPlace" a
valid identifier?

No (starts with a digit)

A programmer names a variable "_userName" to store the username. Is "_userName" a valid
identifier?

No (must start with a letter)

A program tracks the number of windows in a house. Which is the best identifier?

numWindowsHouse

A student writes "2y" to mean "two times y" in an expression. Is "2y" a valid expression?

No (missing multiplication operator)

A program evaluates the expression a - b * c. Which operator is evaluated first?

*

A program evaluates m + 2 * n / 4. Which parenthesization matches the actual evaluation
order?

m + ((2 * n) / 4)

An inventory program runs: numItems = 4; totCount = 3 + (2 numItems) 5. What is the value
of totCount?

, 43

A programmer tries to name a loop counter "while". Is "while" a valid identifier?

No (reserved word)

A program needs to compute "5 more than triple x". Which expression correctly captures
this?

(3 * x) + 5

A shipping company charges: "Too heavy" if weight > 200, "Warning" if weight > 180, else
"OK". Which if statement type is needed?

If-elseif

An age permissions program runs: if userAge == 16 Put "Drive"; elseif userAge == 18 Put
"Vote"; elseif userAge == 21 Put "Drink"; else Put "Kid". What is output if userAge is 19?

Kid

A countdown program iterates: i = 0; while i < 12; i = i + 1. How many times will the loop
iterate?

12

A programmer writes a counter: x = 1; while x != 10; Put x; x = x + 4. What is the result of
running this code?

Infinite loop (x skips over 10)

A program prints a grid of coordinates: row = 0; while row < 2; col = 0; while col < 3; Put row,
col, " "; col = col + 1; row = row + 1. What is the output?

00 01 02 10 11 12

A program collects user input until the user enters -1. Write the loop expression.

userNum != -1

A program counts iterations: for i = 0; i < 4; i = i + 1; Put i; Put " ". What is the output?

0123

A chatbot keeps asking for user input until the user types "quit". Which control structure
should be used?

While loop

Document information

Uploaded on
September 18, 2026
Number of pages
7
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$24.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
300
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions