Which of the following is a valid data validation check for numeric input such as age?

Study for the End of Year 8 Computer Science Test. Prepare with flashcards and multiple choice questions, each with hints and explanations. Get ready for your exam!

Multiple Choice

Which of the following is a valid data validation check for numeric input such as age?

Explanation:
For numeric input like age, you want to ensure the value is a whole number and makes sense in the real world. Requiring the input to be a positive integer achieves this by enforcing both the numeric type (it's a number) and the domain rule (ages are counted in whole years and are not negative). This rejects decimals, fractions, and negative numbers, and rejects non-numeric characters altogether. The other checks would not validate a numeric age: requiring a string of letters would fail the numeric requirement, a boolean value isn’t a numeric type, and needing symbols would also make valid ages invalid.

For numeric input like age, you want to ensure the value is a whole number and makes sense in the real world. Requiring the input to be a positive integer achieves this by enforcing both the numeric type (it's a number) and the domain rule (ages are counted in whole years and are not negative). This rejects decimals, fractions, and negative numbers, and rejects non-numeric characters altogether. The other checks would not validate a numeric age: requiring a string of letters would fail the numeric requirement, a boolean value isn’t a numeric type, and needing symbols would also make valid ages invalid.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy