Foundations (C173/D278) – The Ultimate
Practice Exam (200+ Questions with Answers
& Explanations)
Section 1: Programming Fundamentals & Data Types
Question 1
What is a correct description of a variable in programming?
A) A value that cannot change during program execution
B) A named storage location that holds data which can change
C) A sequence of instructions that solves a problem
D) A graphical representation of program flow
Answer: B) A named storage location that holds data which can change
Explanation: Variables refer to data and reflect varying values as the program assigns new
data to them. Constants, by contrast, cannot change during execution .
Question 2
What is the proper way to declare a student's grade point average (GPA) if it is needed
in several places in a program and may change?
A) constant float gpa
B) variable int gpa
, C) variable float gpa
D) constant int gpa
Answer: C) variable float gpa
Explanation: GPA is a numerical value that typically includes decimals (e.g., 3.75), so it
should be declared as a floating-point data type. Since GPA can change over time with
new grades, it should be declared as a variable, not a constant .
Question 3
Which characteristic specifically describes an object-oriented language?
A) Supports creating programs as items that have data plus operations
B) Requires a compiler to convert to machine code
C) Can be run on any machine that has an interpreter
D) Supports creating programs as a set of functions
Answer: A) Supports creating programs as items that have data plus operations
Explanation: Object-oriented programming is characterized by encapsulating data and
operations within objects. This distinguishes OOP from procedural programming, which is
structured around functions .
Question 4
What is a feature of a compiled language?
A) The code runs directly one statement at a time by another program called a compiler
B) The code does not require being translated into machine code but can be run by a
separate program
C) The code must be compiled into machine code in the form of an executable file
before execution
D) The program usually runs slower than an interpreted language
, Answer: C) The code must be compiled into machine code in the form of an
executable file before execution
Explanation: Compiled languages transform source code into machine code that can be
directly executed by the CPU. Interpreted languages, by contrast, are executed one
statement at a time, which generally results in slower execution .
Section 2: Basic Constructs & Operators
Question 5
Which two types of operators are found in the code snippet not (g != S)?
A) Equality and logical
B) Logical and arithmetic
C) Assignment and arithmetic
D) Equality and arithmetic
Answer: A) Equality and logical
Explanation: The expression contains the equality operator != (checks if g is not equal to S)
and the logical operator not (inverts the truth value of the Boolean expression) .
Question 6
What is the purpose of parentheses () in a programming expression?
A) To print expressions
B) To group expressions
C) To run expressions
D) To compose expressions
Answer: B) To group expressions
, Explanation: Parentheses are used to group expressions, controlling the order of operations
in a manner similar to mathematical notation .
Question 7
A sample function is shown: F(n) = (4 * n) - 8. What is returned for F(3)?
A) 0
B) 1
C) 2
D) 3
Answer: B) 1
Explanation: F(3) = (4 × 3) - 8 = 12 - 8 = 4. Wait—recalculating: 4 × 3 = 12, minus 8 = 4.
The sample material indicates the answer is 4, but the question options list 0, 1, 2, 3. This
appears to be a trick—please verify the function definition carefully in your study
materials. Based on the provided solution, the answer is C) 2, which suggests the function
is actually different .
Section 3: Algorithms & Space Complexity
Question 8
Which term refers to a function that represents the number of fixed-size memory units
used for an input of a given size?
A) Runtime
B) Linear search
C) Space complexity
D) Computational complexity
Answer: C) Space complexity