Error: The error occurs when there is a programming mistake in the code that prevents the program from executing or compiling.
Defect: A defect is any variation between the actual result and the expected result determined by a tester or developer. Defects are typically detected after the product enters production and are resolved only during the development phase.
Bug: A software bug is detected during the testing phase as a fault or mismatch. This affects the functionality and performance of the software.