Skip to main content
Northern IrelandSoftware Systems DevelopmentSyllabus dot point

How do methods with parameters and return values structure a program, and how are strings manipulated?

Methods, parameters and arguments, return values, variable scope, and common string-handling operations.

A CCEA A-Level Software Systems Development answer on methods and parameters: passing arguments, returning values, local and global scope, and common string-handling operations such as length, substring and concatenation.

Generated by Claude Opus 4.812 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

CCEA expects you to write and explain methods that take parameters and return values, and to understand variable scope (local versus global). You must distinguish a parameter (the input in the definition) from an argument (the value supplied at the call), explain why returning values and passing parameters is preferable to relying on globals, and carry out common string-handling operations. Methods are how object oriented programs are decomposed, so they recur everywhere.

The answer

Methods, parameters and arguments

method calculateArea(width, height) returns integer   // two parameters
    return width * height
end method

a = calculateArea(5, 3)   // 5 and 3 are arguments; a becomes 15

When the method is called, each argument is copied into the matching parameter. The method body uses the parameters as local values, and return sends a result back. Decomposing a program into methods reduces duplication, aids testing and makes code readable.

Variable scope

Two methods may each have a local variable called count without interfering, because each count exists only in its own method. A global count, by contrast, can be changed anywhere, which makes tracking its value harder.

String handling

Strings are sequences of characters, and CCEA expects fluency with common operations:

  • length of a string (number of characters)
  • concatenation (joining with + or a join operation)
  • substring / slice (extracting part of a string by position)
  • character access by index
  • case conversion (to upper or lower case)
  • search for a character or substring (find its position)
name = "Aoife"
print(length(name))          // 5
print(upper(name))           // "AOIFE"
greeting = "Hi " + name      // "Hi Aoife"  (concatenation)
print(substring(name, 0, 2)) // "Ao"  (first two characters)

Worked example: a method that builds initials

Examples in context

Example 1. Validating a postcode. A method isValidPostcode(code) takes the entered string as a parameter, uses string-handling operations (length, character checks) to test the format, and returns a Boolean. Because it returns a value rather than touching globals, it can be reused by the registration form, the checkout and the address book without change.

Example 2. A reusable rounding method. A method roundTo(value, places) takes two parameters and returns the rounded number. Its local variables (intermediate calculations) do not leak out, so calling it from several places gives consistent results with no risk of one call corrupting another's data.

Try this

Q1. Distinguish between a parameter and an argument. [2 marks]

  • Cue. A parameter is the named input in the method definition; an argument is the actual value passed in when the method is called.

Q2. State what is meant by the scope of a variable, and give the scope of a variable declared inside a method. [2 marks]

  • Cue. Scope is the region of the program where the name can be used; a variable declared inside a method has local (method-level) scope.

Q3. Given word = "computer", state the result of length(word) and substring(word, 0, 3). [2 marks]

  • Cue. length(word) is 8; substring(word, 0, 3) is "com".

Exam-style practice questions

Practice questions written in the style of CCEA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

CCEA 20186 marksWrite a method `isEven` that takes an integer parameter and returns a Boolean indicating whether it is even. Explain the terms parameter and return value in your answer.
Show worked answer →

A parameter is a named input listed in a method's definition that receives a value (the argument) when the method is called. A return value is the result the method sends back to the caller.

method isEven(number) returns Boolean
    if number MOD 2 = 0 then
        return true
    else
        return false
    end if
end method

Here number is the parameter; when called as isEven(8), the argument 8 is copied into number. The method computes number MOD 2, and because 8 MOD 2 is 0, it returns true. The returned Boolean can then be used, for example if isEven(8) then ....

Markers reward a correct definition of parameter (input) and return value (output), a method that uses MOD (or equivalent) to test evenness, and a correct Boolean return for both cases.

CCEA 20225 marksExplain the difference between a local variable and a global variable, and state one advantage of using local variables and parameters rather than global variables.
Show worked answer →

A local variable is declared inside a method and exists only while that method runs; it cannot be seen or changed by other methods. A global variable is declared outside all methods and is visible to the whole program, so any method can read or change it.

The scope of a variable is the region of the program in which it can be used. Local variables have a method-level scope; global variables have program-level scope.

An advantage of local variables and parameters is that they reduce unwanted side effects and make code easier to maintain and test: data passed in through parameters and returned through return values keeps each method self-contained, so a change in one method cannot accidentally corrupt a value relied on elsewhere. Overusing globals makes it hard to track where a value was changed.

Markers reward the local-versus-global distinction tied to scope, and a genuine advantage such as fewer side effects, easier debugging, or better reusability and encapsulation.

Related dot points

Sources & how we know this