AP® Computer Science A glossary
Logic error
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
A mistake in the algorithm or program that makes it behave incorrectly or unexpectedly. Testing with specific data detects it.
Appears in the course and exam description (CED): 1.1.C.2
A logic error compiles and runs, but the result is wrong. Only testing the program with specific data and comparing the output to the expected outcome reveals it.
int length = 5;
int width = 3;
System.out.println(length + width); // should be length * width
Output:
8 Learn it properly, with a checkpoint 1.1 Introduction to Algorithms, Programming, and Compilers