Foundations OA Exam Prep Official Practice
Exam Actual Exam 2026/2027 with Detailed
Rationales | Complete Exam-Style Questions |
Pass Guaranteed – A+ Graded
══════════════════════════════════════
SECTION 1: PROGRAMMING FUNDAMENTALS Q1 – Q10
══════════════════════════════════════
Question 1 of 50
A student is writing a program to calculate the average of three test scores. The pseudocode
declares score1 = 85, score2 = 90, score3 = 78, then computes average =
score1 + score2 + score. The student expects 84.3 but gets 111.0 instead.
A. The division operator has higher precedence than addition, so only score3 is divided by 3
before the additions occur.
B. The variable average is declared as an integer type, truncating the decimal portion of the
result.
C. The addition operations overflow the maximum value allowed for the variable type.
D. The assignment operator cannot handle expressions with both addition and division in the
same statement.
Correct Answer: A
Rationale: Division has higher precedence than addition in standard order of operations, so
the expression evaluates as score1 + score2 + (score) which equals 85 + 90
+ 26 or 201, not the intended (85 + 90 + 78) / 3. The most tempting wrong answer B
suggests integer truncation, but the problem states the result is 111.0 with a decimal, which
rules out simple truncation of the correct calculation. To fix this, the student should use
parentheses around the sum: (score1 + score2 + score3) / 3.
Question 2 of 50
A developer needs to store a user's age in a variable and later check if the user is eligible to
vote. The age must be a whole number without decimals, and the program will perform
arithmetic comparisons. Which data type is most appropriate for the age variable?
,A. String, because ages are commonly displayed as text on forms.
B. Boolean, because eligibility is ultimately a true or false determination.
C. Integer, because age is a whole number and supports mathematical comparison
operations.
D. Float, because it provides the highest precision for any numeric value the user might enter.
Correct Answer: C
Rationale: Age is naturally a whole number, and integer types efficiently support the
comparison operations needed for eligibility checks while using minimal memory. The most
tempting wrong answer D suggests float for precision, but floats introduce unnecessary
decimal complexity and potential rounding errors for a value that should never have fractional
parts. Choose the simplest data type that accurately represents your data to avoid subtle
bugs from type mismatches.
Question 3 of 50
A program declares x = 5, y = 2, then evaluates the expression result = x % y + x /
y. The student traces the code and needs to determine the final value stored in result.
A. 3.5
B. 2.5
C. 4.0
D. 3.0
Correct Answer: B
Rationale: The modulus 5 % 2 evaluates to 1 (the remainder of 5 divided by 2), and integer
division evaluates to 2.5 in languages with true division, so 1 + 2.5 = 3.5... wait,
let me recalculate: if this is integer division returning 2, then 1 + 2 = 3. Actually with
standard precedence, % and / have equal precedence and left-to-right associativity, so 5 % 2
is 1, then 1 + where is 2.5, giving 3.5. Hmm, but if integer division:
= 2, so 1 + 2 = 3. The correct answer here assuming integer division behavior is 3.0, but
let me reconsider: in many introductory contexts, with integers gives 2, making 1 + 2
= 3. So the answer is D.
Correct Answer: D
Rationale: The modulus operator % has the same precedence as division and evaluates left to
right, so 5 % 2 yields 1 first, then using integer division yields 2, and finally 1 + 2
equals 3. The most tempting wrong answer A assumes true division giving 2.5, but in many
foundational programming contexts integer division truncates to 2 when both operands are
integers. Always verify whether your language uses integer division or floating-point division
when both operands are integers, as this dramatically changes results.
, Question 4 of 50
A program prompts the user to enter their hourly wage and hours worked, storing them in
variables wage and hours. The program then calculates pay = wage * hours and
outputs the result. The user enters 15.50 for wage and 40 for hours, but the program outputs
620 instead of 620.0. What most likely caused this discrepancy?
A. The wage variable was declared as an integer type, truncating 15.50 to 15 before
multiplication.
B. The output statement automatically formats numeric values without decimal places when
the result is a whole number.
C. The hours variable was declared as a string, causing concatenation instead of
multiplication.
D. The pay variable overflowed its maximum storage capacity and rounded to the nearest
whole number.
Correct Answer: B
Rationale: Many output functions automatically suppress trailing zeros and the decimal point
when displaying whole numbers, so 620.0 renders as 620 even though the internal value
remains correct. The most tempting wrong answer A suggests truncation, but that would
produce 600 (15 * 40), not 620. When debugging output formatting issues, always distinguish
between the actual stored value and how the display function chooses to format it.
Question 5 of 50
A student writes pseudocode to swap the values of two variables, a = 10 and b = 20,
using a = b followed by b = a. After execution, both variables hold 20. The student needs a
correct approach.
A. Declare a = 20 and b = 10 directly, bypassing the need for a swap algorithm.
B. Use a temporary variable: temp = a, a = b, b = temp.
C. Add the values first: a = a + b, b = a - b, a = a - b.
D. Assign both variables simultaneously using parallel assignment syntax.
Correct Answer: B
Rationale: A temporary variable preserves the original value of a before it gets overwritten by
b, allowing the complete swap to occur without data loss. The most tempting wrong answer
C describes a valid arithmetic swap technique, but it risks integer overflow with large values
and is harder to read than the temporary variable approach. The temporary variable method is
the most readable, safest, and universally applicable swap technique across all programming
languages.
Question 6 of 50