Foundations Pre-Assessment Exam –
Complete 220 Questions with Verified
Detailed Answers
Official Exam Overview:
The WGU D278 Pre-Assessment Exam evaluates learners’ understanding of programming
fundamentals, including data types, variables, constants, control structures, and best practices in
coding. The exam emphasizes writing efficient and maintainable code using proper declarations,
data handling, and program logic.
Exam Coverage Areas:
• Data Types, Variables, and Constants
• Operators and Expressions
• Control Structures (Loops, Conditionals)
• Functions and Procedures
• Input/Output Handling
• Program Logic and Debugging
• Best Coding Practices
• Multiple Choice and Short Answer Question Formats
QUESTION 1: A program uses the number of seconds in a minute in various calculations. How
should the item that holds the number of seconds in a minute be declared?
a) Constant float userTime
b) Variable float userTime
c) Constant integer secondsPerMinute ✅
d) Variable integer secondsPerMinute
Rationale: The number of seconds in a minute is fixed, so it should be declared as a constant
integer to prevent accidental changes and ensure accuracy in calculations.
QUESTION 2: Which declaration is appropriate for a value that may change during program
execution?
a) Constant ✅
b) Variable ✅
c) Literal
d) Static
Rationale: Variables are used for values that can change during program execution, whereas
constants remain fixed.
QUESTION 3: What is the main advantage of using constants in a program?
,a) They save memory
b) They prevent accidental modification of fixed values ✅
c) They speed up program execution
d) They are easier to declare
Rationale: Using constants ensures that critical fixed values cannot be accidentally altered,
improving program reliability and maintainability.
QUESTION 4: Which data type is best suited for storing whole numbers?
a) Float
b) Integer ✅
c) String
d) Boolean
Rationale: Integer types store whole numbers without fractional parts, suitable for counting or
indexing operations.
QUESTION 5: If a program frequently uses a fixed conversion factor, it is best to:
a) Hardcode it in every calculation
b) Declare it as a constant ✅
c) Declare it as a variable
d) Ignore it
Rationale: Declaring a frequently used fixed value as a constant reduces errors, simplifies
maintenance, and improves code clarity.
Page 1 of 32
QUESTION: A program uses the number of seconds in a minute in various calculations.
How should the item that holds the number of seconds in a minute be declared?
A Constant float userTime
B Variable float userTime
C Constant integer secondsPerMinute
D Variable integer secondsPerMinute - ANSWER-Constant Integer secondsPerMinute
QUESTION: A program determines if a user's age is high enough to run for U.S. president. The
minimum age requirement is 35.
,How should the item that holds the minimum age be declared?
A Constant integer minAge
B Variable integer minAge
C Constant integer 35
D Variable integer 35 - ANSWER-Constant integer minAge
QUESTION: Given integer x = 3 and integer y = 5.
What is the value of the expression ( x / 2.0) + y?
A 5.0
B 6.0
1
, Page 2 of 32
C 6.5
7 7.5 - ANSWER-6.5
QUESTION: Given float x = 10.2 and float y = 1.0.
What is the value of the expression x / y ?
A 0.0
B 1.0
C 10
D 10.2 - ANSWER-10.2
Which operator should be used to determine if a number is evenly divisible by 5?
A+
B-
C*
D % - ANSWER-%
QUESTION: A car drove 200 miles using 10 gallons of fuel.
Which operation should be used to compute the miles per gallon, which is 20?
A Addition
B Subtraction
C Multiplication
D Division - ANSWER-Division
QUESTION: A variable should hold a person's height in meters.
2