Question Detail

COS 102 test topic Objective Question

Question

What constitutes a 'side effect' of a function call?
Options
A The function computes and returns an intended scalar value
B The function modifies state outside its local environment, such as changing a global variable
Correct Answer
C The function executes in linear time
D The function encounters an unreachable code path
Correct Answer

Option B is the correct answer.

Detailed Explanation

A side effect occurs when an operation mutates state outside its local execution boundary, such as I/O operations or global mutations.

Hint

No hint available

Question Info