Skip to content

Course home

Robust and secure programming

Robust and secure programming

EasyMediumHard
12345678
Question 1

A software engineer is developing a robust payment processing system. During test execution, two distinct bugs are identified:

  1. A division-by-zero crash occurs when the number of split-bill participants is entered as 0. The program terminates abruptly.
  2. A tax calculation bug where the system uses tax_rate×0.1\text{tax\_rate} \times 0.1tax_rate×0.1 instead of tax_rate×0.01\text{tax\_rate} \times 0.01tax_rate×0.01, resulting in incorrect invoice amounts, though the program runs to completion without any warnings.

Which statement correctly classifies these bugs and describes how they interact with translation (compilation/interpretation) and defensive programming?

A

Bug 1 is a runtime error and Bug 2 is a logic error. A standard compiler or interpreter cannot detect either of these bugs during translation; instead, input validation and defensive programming are required to prevent Bug 1.

B

Bug 1 is a syntax error and Bug 2 is a logic error. The compiler's syntax analyzer will fail to translate the program if a division by zero is mathematically possible, whereas Bug 2 can only be caught using exception handling blocks.

C

Bug 1 is a runtime error and Bug 2 is a syntax error. Bug 2 will prevent successful compilation because the tax rate multiplier violates the language rules, whereas Bug 1 requires a dry run with trace tables to identify.

D

Bug 1 is a logic error and Bug 2 is a runtime error. Both errors will cause the interpreter to halt execution immediately, and both can be successfully prevented by incorporating strict type checking at the compilation stage.

Markscheme

Robust and secure programming Questions

  1. GCSE
  2. /Computer Science
  3. /Robust and secure programming

27 exam-style questions on AQA GCSE Computer Science Robust and secure programming. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank