Lesson 4.1.1.11

4.1.1.11 Parameters and returning values Quiz: AQA Computer Science, Unit 1

20 questions

In partnership with Revision Ninja

Lesson 4.1.1.11, Parameters and returning values: 20 multiple choice questions for the AQA Computer Science (7517), Unit 1: Fundamentals of programming, written with Revision Ninja.

Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.

Host this setFree Play

The 20 questions

  1. What is a parameter of a subroutine?

    • A record type stored on disk, which holds the fields of a file that the subroutine reads
    • A loop that runs inside the subroutine, repeating its statements a fixed number of times
    • A constant that is always global, so every part of the program can read its fixed value
    • A value passed into the subroutine so it can use data from the caller
  2. What is the purpose of a subroutine's interface?

    • It states the parameters and return type, so callers know how to use it
    • It makes the subroutine run in a separate file, so that it is compiled independently of the program
    • It stores the subroutine's local variables permanently, so their values survive after each call
    • It draws the output on screen automatically, so the display is set without any output statements
  3. A function is defined as calculateArea(width, height) and returns width times height. What are width and height?

    • Constants
    • Parameters
    • Global variables only
    • Return addresses
  4. A subroutine returns a value to the calling routine. Which statement is correct?

    • The caller cannot use the returned value, because only the subroutine is allowed to read it
    • The returned value is lost unless it is printed, because the caller cannot store results in memory
    • The returned value must be a Boolean, so that the caller can test it in a selection statement
    • The caller can use the returned value in an assignment or expression
  5. A function called getMax takes two integers and returns the larger. It is called with getMax(7, 12). What is returned?

    • 19
    • 12
    • 7
    • 5
  6. A subroutine is called with the arguments (3, 4) and it adds them and returns the result. What is the returned value?

    • 12
    • 34
    • 7
    • 1
  7. What is the difference between a parameter and an argument?

    • An argument is the name in the definition, while a parameter is the value passed in a call
    • A parameter is the name in the definition, while an argument is the value passed in a call
    • They are two names for the same thing with no difference
    • A parameter is always a constant and an argument is always a variable
  8. A subroutine uses a parameter to receive a student's name and prints a welcome message. Which is the best reason for using the parameter?

    • So the name is stored as a constant forever, which stops the name from being changed later on
    • So the output is always the same name, which keeps the greeting consistent for all students
    • So the same subroutine can greet any name without being rewritten
    • So the subroutine does not need a call, because the parameter makes the code run automatically
  9. A subroutine returns a result but the calling code ignores it. What happens to the subroutine's code?

    • The program stops with an error, since every returned value must be stored by the caller
    • It is not executed at all, because a result that is never used means the subroutine is skipped
    • The result is automatically printed, so the program shows the value on screen without help
    • It still runs, but the returned value is not used
  10. A procedure has three parameters. How many values must the caller supply if all three are needed?

    • 3
    • 1
    • 0
    • 2
  11. Which statement about passing data with parameters is most accurate?

    • Parameters are the same as local variables with no link to callers, so no data ever passes in
    • Parameters let data move between the caller and the subroutine without using shared globals
    • Parameters are only used for returning results, so input values are always read from globals
    • Parameters must always be strings, so numbers have to be converted to text before the call
  12. A function returns the average of three values passed in as parameters. Which expression returns the correct average for 4, 6 and 8?

    • (4 + 6 + 8) DIV 2
    • 4 + 6 + 8 / 3
    • (4 * 6 * 8) / 3
    • (4 + 6 + 8) / 3
  13. A subroutine is written to take a real parameter, but the caller passes a string. What is the most likely outcome?

    • The subroutine converts the string to a real automatically in every language
    • The subroutine always returns zero
    • The subroutine runs with a constant value
    • A type mismatch error, or the value is not used as intended
  14. Why is it good practice to define an interface for a subroutine before writing its body?

    • It makes clear what inputs are needed and what output is produced
    • It stops the subroutine from being called, which keeps the body of the code protected from change
    • It removes the need to test the subroutine, because a clear interface means no errors can occur
    • It converts all parameters to Booleans, so the subroutine checks every input for TRUE or FALSE
  15. A function returns the square of a parameter. What is returned when the function is called with 5?

    • 5
    • 15
    • 25
    • 10
  16. A function returns the number of characters in a string passed as a parameter. The string "CPU" is passed. What is returned?

    • 0
    • 2
    • 4
    • 3
  17. A subroutine takes a parameter used as an index into an array. Why is the index value important to the call?

    • Passing an invalid index can make the subroutine access the wrong data or fail
    • An index parameter is never used with arrays, because an array's elements are found by value instead
    • Indexes are converted to strings automatically, so the array search uses text matching instead
    • Indexes are always ignored by subroutines, which pass the array directly without any index at all
  18. Which combination of parameters and a return value is best for a function that calculates the cost of petrol from litres and price per litre?

    • No parameters and a returned cost constant, so the cost is always the same whatever the petrol
    • Two parameters, litres and price, and a returned cost
    • Two returned values and no parameters, so the function outputs both litres and price to the caller
    • A global variable only with no return, so the cost is stored and read later by any part
  19. A function is called as average(10, 20). If the function returns the mean of its two parameters, what is returned?

    • 15
    • 20
    • 10
    • 30
  20. A subroutine takes a parameter and returns the parameter multiplied by 10. The caller passes 4 and stores the result. What is stored?

    • 14
    • 4
    • 400
    • 40

All AQA Computer Science quizzes