Revisionโ€บOCR GCSEโ€บProducing Robust Programs
OCR GCSE J277 ยท Topic 2.3

Producing Robust Programs

65 practice questions

Practice Questions

65 questions

What is the difference between a syntax error and a logic error?

easy

What is a runtime error?

easy

A programmer writes: IF x = 5 THEN (missing the closing keyword ENDIF). What type of error is this?

easy

A program is designed to calculate the average of three numbers but instead divides the total by 2. The program runs without crashing but gives incorrect results. What type of error is this?

medium

Why are logic errors often harder to detect than syntax errors?

medium

A program attempts to open a file that does not exist, causing the program to crash with an error message. What type of error has occurred?

medium

Which type of error would prevent a program from being run/compiled at all?

easy

A program calculates BMI using the formula weight / height (missing the squaring of height). The program runs and gives an output, but the BMI values are incorrect. Classify this error and explain why.

medium

A user enters a non-numeric value into a program that then tries to perform a calculation with it, causing the program to crash. What type of error is this, and how could it be prevented?

hard

Explain the difference between an error that occurs when a program is run (runtime error) and one that prevents the program from running at all (syntax error).

medium

What is the difference between validation and verification?

medium

Give THREE types of validation check with an example of each.

medium

A form requires a user to enter their date of birth. Which validation check would ensure the field has not been left blank?

easy

A program requires a UK phone number to be entered as exactly 11 digits. Which validation check would be used to ensure this?

easy

A program asks the user to enter a percentage, which must be between 0 and 100. The user enters 150. Which validation check would detect this as invalid?

easy

Explain why input validation cannot guarantee that data is correct (accurate), only that it is reasonable.

hard

A program expects the user to enter a whole number for "quantity", but the user types "five". Which validation check would catch this error?

easy

Write pseudocode for an input validation loop that repeatedly asks the user to enter a number between 1 and 10 until a valid value is entered.

medium

A user must enter an email address containing an "@" symbol. Which type of validation check is most appropriate?

medium

Explain why applying input validation as early as possible (e.g. immediately after data entry) is good practice in program design.

medium

What is black-box testing?

easy

What is white-box testing?

easy

A tester checks that entering a username and password on a login form correctly logs the user in or shows an error, without looking at the underlying code. What type of testing is this?

easy

A developer writes a test that specifically checks that every branch of an IF/ELSE statement in their code is executed at least once. What type of testing is this?

medium

Which of the following is an advantage of black-box testing over white-box testing?

medium

Explain why white-box testing might find errors that black-box testing would miss.

hard

A company hires an external tester who has no access to the source code and is simply asked to use the finished application and report any issues. What type of testing is this an example of?

easy

Give one example of a white-box testing technique.

medium

A program has a function that should return "Pass" for marks >= 40 and "Fail" otherwise. A black-box test checks inputs of 39 and 40 and confirms the correct outputs are returned. Is this testing the internal code structure?

medium

Explain why a combination of both black-box and white-box testing is often used when testing software.

hard

What is the purpose of testing?

easy

What are the three categories of test data?

easy

A program accepts ages between 1 and 100. Give an example of normal, boundary, and erroneous test data.

medium

What is the purpose of a test plan?

easy

A test plan table typically includes columns for test data, expected result, and what other column?

easy

What is defensive design?

medium

What is input sanitisation and why is it important for security?

medium

Describe how exception handling improves programme robustness and give an example.

medium

What is "anticipation of misuse" as a defensive design technique?

medium

A program reads a number entered by the user and divides 100 by it. What defensive programming technique would prevent a crash if the user enters 0?

medium

Explain how using a maximum length restriction on a text input field is an example of defensive programming.

medium

Which of the following is an example of a defensive programming technique?

easy

Explain why defensive programming techniques are particularly important for programs that accept input directly from members of the public.

hard

A program is designed to read 10 numbers from a file into an array of size 10. What defensive technique should be used in case the file actually contains more or fewer than 10 numbers?

hard

Give two examples of defensive design techniques that could be used together in a single program to handle unexpected input robustly.

medium

Why is code maintainability important in software development?

easy

Explain why using meaningful variable names improves code quality, with an example.

easy

State three benefits of a modular approach to software design.

medium

What is test-driven development (TDD) and what is the correct order of steps?

hard

Explain why code review is a good practice and state two things a reviewer should check.

medium

What is the purpose of consistent indentation in program code?

easy

Give two examples of "naming conventions" a programmer might follow when naming variables.

easy

A program contains the comment: "# This loop adds up all the values in the scores array and stores the result in total". What is the purpose of this comment?

easy

Explain how poor indentation in a program with nested IF statements and loops could make the code harder to maintain, even if the program runs correctly.

medium

Which of the following sets of variable names follows good naming convention practice for readability?

easy

A programmer is asked to update code they wrote two years ago, but it has no comments, inconsistent indentation, and variables named a, b, and temp1. Explain why this would make the update more time-consuming.

medium

Which of these is NOT typically considered a maintainability feature?

easy

Explain how breaking a program into well-named procedures/functions (rather than one long block of code) improves maintainability.

medium

A team of programmers agrees that all Boolean variables in their project will be named starting with "is" or "has" (e.g. isValid, hasPermission). What is this an example of?

medium

Explain why maintainability is especially important for software that is expected to be used and updated for many years.

hard

A test plan includes the column headings: Test number, Purpose, Test data, Expected result, Actual result. Why is it useful to include "Expected result" alongside "Actual result"?

medium

A program validates that a password must be between 8 and 16 characters long. Which of the following is a boundary test data value?

medium

Design a test plan entry (test data and expected result) to check that a program correctly rejects invalid (erroneous) input for a field that must contain a whole number between 1 and 6 (e.g. a dice value).

medium

Why should a thorough test plan include normal, boundary, AND erroneous test data, rather than just normal data?

medium

A program asks for a student's exam mark out of 100. Complete a test plan row for testing with the erroneous value -10, including the expected result.

medium