easyMultiple Choice
FC0-U71 Practice Question: A junior developer is tasked with creating a…
A junior developer is tasked with creating a function that checks whether a number is even or odd. The developer writes the following pseudocode: FUNCTION isEven(number) IF number % 2 == 0 THEN RETURN true ELSE RETURN false. The developer then realizes they need to handle non-integer input. Which of the following should the developer add to improve the robustness of this function?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Add input validation to check if the number is an integer.
Adding input validation to check if the number is an integer ensures the modulus operation works correctly. A parameter for number type is not standard. Changing the operator would break the logic. Deleting and using a library is overkill.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Add input validation to check if the number is an integer.
Why this is correct
Non-integer input such as 3.5 or text would otherwise pass silently into the modulo check and return misleading results. Validating that the argument is an integer before evaluating parity rejects invalid values early, satisfying the stem's robustness requirement for handling non-integer input.
- ✗
Delete the function and use a built-in library instead.
Why it's wrong here
Replacing the function with a library call does not add the non-integer handling the stem asks for; it just relocates the same gap. It is tempting because mature libraries often validate input already, which is sensible when writing general-purpose numeric utilities, but here the task is to harden this specific function.
- ✗
Change the modulus operator to a division operator.
Why it's wrong here
Division does not test parity: number / 2 yields 1.5 for odd integers, so the equality check against 0 never holds and every input returns false. It is tempting because division and modulus are related arithmetic operations, but modulus is precisely the operator that isolates the remainder parity depends on.
- ✗
Add a parameter for the number type.
Why it's wrong here
Adding a type parameter does not reject or convert non-integer values; the function still runs modulus on whatever arrives. It is tempting because typed parameters are a genuine robustness technique in statically typed languages, but the stem needs runtime validation of the incoming value, not a declared type.
About these practice questions
This FC0-U71 question is part of Courseiva's 988-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.