APCSP APCSP Program Design and Development 2 — Questions and Answers
Question 1: What is a 'test case' in software development?
- A folder that stores program files
- A specific set of inputs used to verify a program produces expected outputs (Correct answer)
- A type of loop that repeats until an error occurs
- A comment block at the top of a file
Correct answer: A specific set of inputs used to verify a program produces expected outputs
A test case defines known inputs and their expected outputs, allowing developers to verify program correctness systematically.
Question 2: Which scenario best illustrates 'edge case' testing?
- Testing the program with typical, average inputs
- Testing the program with the largest or smallest valid values and boundary conditions (Correct answer)
- Only running the program once to see if it launches
- Testing on a different computer than the one used for development
Correct answer: Testing the program with the largest or smallest valid values and boundary conditions
Edge cases test the boundaries of valid input ranges, where bugs are most likely to occur in conditional logic.
Question 3: What is the role of a 'specification' in program development?
- A tool that automatically fixes bugs
- A document that describes what a program should do before it is built (Correct answer)
- A list of all variables used in the program
- A command that compiles code into machine language
Correct answer: A document that describes what a program should do before it is built
A specification defines the expected behavior, inputs, and outputs of a program, guiding development and testing.
Question 4: Why is it important to test a program with invalid inputs?
- Invalid inputs always crash programs by design
- Programs should handle unexpected inputs gracefully without crashing (Correct answer)
- Testing invalid inputs is not required in AP CSP
- Invalid inputs are automatically blocked by the CPU
Correct answer: Programs should handle unexpected inputs gracefully without crashing
Robust programs handle invalid inputs by displaying errors or using defaults rather than crashing or producing wrong results.
Question 5: What does 'debugging' involve?
- Adding new features to make a program faster
- Identifying and fixing errors so a program behaves as intended (Correct answer)
- Compiling the program into an executable file
- Deleting old versions of the code
Correct answer: Identifying and fixing errors so a program behaves as intended
Debugging is the process of locating logical, syntax, or runtime errors and correcting them so the program runs correctly.
Question 6: Which type of error causes a program to produce incorrect results without crashing?
- Syntax error
- Runtime error
- Logic error (Correct answer)
- Compilation error
Correct answer: Logic error
A logic error means the program runs successfully but produces wrong output because the algorithm is flawed.
What is a 'test case' in software development?