Back to the topic

The mark scheme starts on a new page, so you can print pages one and two for a student and keep the last page yourself. Everything prints in black on white whichever theme you are using.

AQA GCSE CS · 3.2.12

Robust and Secure Programming

Section A: 10 multiple choice questions, 10 marks. Section B: 5 written questions, 15 marks. Total 25 marks.

Name

Class

Date

Mark  / 25

Section A

Circle the letter of the correct answer. One mark each.

  1. 1A program will not run and the translator reports a missing bracket. What kind of error is this?1
    1. ALogic error
    2. BRuntime error
    3. CSyntax error
    4. DValidation error
  2. 2A program runs but calculates the average by dividing by the wrong number. What kind of error is this?1
    1. ARuntime error
    2. BSyntax error
    3. CLogic error
    4. DType error
  3. 3Which validation check would stop a user leaving a name box empty?1
    1. APresence check
    2. BLength check
    3. CFormat check
    4. DRange check
  4. 4For an input that must be between 1 and 10, which set is boundary test data?1
    1. A1, 2, 3
    2. B0, 1, 10, 11
    3. Ccat, empty, 3.5
    4. D5, 6, 7
  5. 5What can validation never do?1
    1. ACheck a required field is not empty
    2. BCheck a value is within a range
    3. CCheck data is of the right type
    4. DConfirm that the data entered is truthful
  6. 6What is the purpose of authentication?1
    1. ATo find syntax errors
    2. BTo check that a user is who they claim to be
    3. CTo make a program run faster
    4. DTo check that data entered is sensible
  7. 7A program stops with an error when it tries to open a file that has been deleted. What kind of error is this?1
    1. ADesign error
    2. BRuntime error
    3. CSyntax error
    4. DLogic error
  8. 8Which of these most improves the maintainability of a program?1
    1. AMaking the program shorter by removing indentation
    2. BRemoving all comments
    3. CUsing single letter variable names to save typing
    4. DUsing meaningful identifier names
  9. 9Why is iterative testing carried out during development rather than only at the end?1
    1. AFaults are found while the code is small and recent, so they are cheaper to fix
    2. BIt is required by law
    3. CIt removes the need for final testing
    4. DIt makes the program run faster
  10. 10What is erroneous test data used to check?1
    1. AThat the program is fast enough
    2. BThat the program handles typical values
    3. CThat the boundaries are correct
    4. DThat the program correctly rejects data it should not accept

Section B

Answer in the space provided. The number of marks tells you how many separate points to make.

  1. 1StateState what is meant by validation.1
  2. 2GiveA program asks for a percentage mark between 0 and 100. Give one item of normal test data, one item of boundary test data and one item of erroneous test data.3
  3. 3ExplainExplain the difference between a logic error and a syntax error.4
  4. 4ExplainA shopping website validates the postcode a customer enters. Explain why validation alone cannot guarantee the parcel will arrive.3
  5. 5DescribeDescribe two ways in which a programmer can make a program easier to maintain.4

Mark scheme

Section A

1C2C3A4B5D6B7B8D9A10D

Section B

1 State what is meant by validation. 1

One mark for each of the following, to a maximum of 1.

  • An automatic check that data entered is sensible or reasonable

Model answer. Validation is an automatic check carried out by a program to make sure that data entered is reasonable and of the form expected.

2 A program asks for a percentage mark between 0 and 100. Give one item of normal test data, one item of boundary test data and one item of erroneous test data. 3

One mark for each of the following, to a maximum of 3.

  • Normal data is a typical value inside the range, such as 55
  • Boundary data is at the edge of the range, such as 0, 100, -1 or 101
  • Erroneous data is something that should be rejected, such as a word or a blank entry

Model answer. Normal test data would be 55, a value comfortably inside the acceptable range that the program should accept. Boundary test data would be 0 and 100, the two limits, together with -1 and 101 just outside them, since an incorrect comparison would only show up there. Erroneous test data would be a word such as cat, or a blank entry, which the program should reject rather than process.

3 Explain the difference between a logic error and a syntax error. 4

One mark for each of the following, to a maximum of 4.

  • A syntax error breaks the rules of the programming language
  • A program containing a syntax error will not run, and the translator reports it
  • A logic error means the program runs but produces the wrong result
  • Nothing reports a logic error, so it must be found by testing or by tracing the program

Model answer. A syntax error breaks the rules of the programming language, for example a missing bracket or a misspelled keyword. The translator cannot make sense of the line, so the program will not run at all and the error is reported, usually with a line number, which makes it comparatively easy to fix. A logic error is different in kind. The code is perfectly valid, so the program translates and runs, but the instructions do not do what the programmer intended, so the output is wrong. Nothing reports it, which means it can only be found by testing with data whose correct answer is already known, or by tracing the program by hand.

4 A shopping website validates the postcode a customer enters. Explain why validation alone cannot guarantee the parcel will arrive. 3

One mark for each of the following, to a maximum of 3.

  • Validation only checks that the data is of a reasonable form
  • A postcode can be correctly formatted but not be the customer's actual postcode
  • Validation cannot check truthfulness, only plausibility

Model answer. Validation checks the shape of the data, so a format check can confirm that the entry looks like a postcode and a look up check can confirm that it is a postcode that exists. Neither of those establishes that it is the right postcode for this customer. Somebody can enter a real, correctly formatted postcode belonging to a different address, either by mistake or deliberately, and every check will pass. Validation tests whether data is plausible, and no automatic check on the data alone can test whether it is true.

5 Describe two ways in which a programmer can make a program easier to maintain. 4

One mark for each of the following, to a maximum of 4.

  • Use meaningful identifier names that say what the value holds
  • So another programmer can understand the code without tracing it
  • Use comments to explain why the code does what it does
  • Use subroutines and indentation so the structure is visible and each task lives in one place

Model answer. The first is to use meaningful identifiers. A variable called totalPrice tells the next reader what it holds, whereas one called tp or x2 has to be traced through the whole program before it can be safely changed. The second is to use subroutines with sensible indentation, so that each task lives in one named place and the structure of the program is visible on the page. Together those mean that a change to how something is calculated is made once, in an obviously named place, with far less risk of breaking something elsewhere. Comments explaining why an unusual decision was taken support both.