• 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 3 Questions with Verified Correct Answers

Document preview thumbnail
Preview 2 out of 7 pages

D278 Practice Exam 3 Questions with Verified Correct Answers

Content preview

D278 Practice Exam 3 Questions with Verified

Correct Answers

A program runs: x = 10; y = x; x = 20. What is the final value of y?

10

A program runs: a = 5; b = 3; a = b; b = a. What is the final value of b?

3

A program tracks the average GPA of a class. Which data type should be used?

Float

A program tracks the number of times a button has been clicked. Which data type should be
used?

Integer

A program needs to store whether a user is logged in. Which data type should be used?

Boolean

Given integer a = 9 and integer b = 4. What is the value of a / b?

2

Given integer a = 9 and integer b = 4. What is the value of a % b?

1

Given integer a = 9 and integer b = 4. What is the value of (a + b) / 2?

6

Given float p = 7.0 and integer q = 2. What is the value of p / q?

3.5

A program checks if userAge is exactly 18 OR exactly 21. Which expression captures this?

(userAge == 18) or (userAge == 21)

A program checks if temperature is below 32 OR above 100. Which expression captures this?

, (temp < 32) or (temp > 100)

Why should a programmer use a constant instead of a regular variable for the value of pi?

The value should not change during program execution

A program has logic: if score >= 90 Put "A"; elseif score >= 80 Put "B"; elseif score >= 70 Put
"C"; else Put "F". What is output if score = 85?

B

A program has logic: if x > 0 then y = 1; if x > 10 then y = 2; if x > 100 then y = 3. Given x = 50,
what is the final value of y?

2

A delivery service: if weight > 100 then fee = 50, else fee = 20. If weight is exactly 100, which
branch executes?

else (false) branch

A program runs: i = 10; while i > 0; Put i; i = i - 2. How many times does the loop iterate?

5

A program runs: i = 1; while i < 20; i = i * 2. How many times does the loop iterate?

5

A program runs: count = 0; while count < 3; Put "Hi"; count = count + 1. What is the output?

HiHiHi

A program runs: x = 5; do; Put x; x = x - 1; while x > 5. What is the output?

5

Why does a do-while loop always execute its body at least once?

The condition is checked after the body executes

A program needs to process exactly each item in a 20-element array. Which loop is preferred?

For loop

A scores array has 10 elements with valid indices 0 to 9. A programmer writes scores[10] = 95.
What happens?

Out-of-bounds error (index 10 is invalid)

Document information

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

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