mediumMultiple Choice
FC0-U71 Practice Question: A programmer needs to store a true/false value
A programmer needs to store a true/false value. Which data type is most appropriate?
⚠ Common exam trap
Candidates may mistakenly think that integers or strings can store true/false values due to type coercion in some languages like JavaScript or Python, but the Boolean type is the correct choice for storing a true/false value.
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
✓
Boolean
A Boolean data type is specifically designed to store true/false values, representing binary logic states. In most programming languages, including Python, Java, and C++, a Boolean variable can only hold one of two values: true or false, making it the most appropriate choice for this requirement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Integer
Why it's wrong here
Integer stores whole numbers, so a Boolean would be encoded as 1 or 0, allowing values like 7 that carry no true/false meaning and requiring convention-based interpretation. Integer is correct for counting and arithmetic; Boolean is the type designed for true/false.
- ✗
String
Why it's wrong here
String stores text characters, so a Boolean would become "true" or "false", consuming more memory and permitting arbitrary text such as "yes" or "banana" that cannot be evaluated as a condition. String suits textual data; Boolean is the type intended for true/false values.
- ✓
Boolean
Why this is correct
Boolean stores exactly two states, true or false, matching the programmer's requirement without wasting memory. Unlike integer or string types, which can hold many values and permit invalid entries, a Boolean constrains input to the binary logic the scenario demands, making it the most appropriate and type-safe choice for a single true/false flag.
- ✗
Float
Why it's wrong here
Float stores fractional numeric values with decimal precision, so a true/false value would be represented as 1.0 or 0.0, losing the Boolean semantics and permitting nonsensical values like 0.5. Float is correct for continuous measurements, whereas Boolean is the type designed for true/false.
Go deeper
Related to this question
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 →
Same concept, more angles
2 more ways this is tested on FC0-U71
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which programming data type would be used to store a value of 'True' or 'False'?
medium- A.String
- B.Float
- ✓ C.Boolean
- D.Integer
Why C: A Boolean data type is specifically designed to hold one of two truth values: True or False. It is named after mathematician George Boole and is fundamental to conditional logic, comparisons, and control flow in programming. Storing 'True' or 'False' in any other type would be semantically incorrect and would lose the type's logical meaning.
Variation 2. Which TWO of the following are valid data types in most programming languages?
easy- ✓ A.Boolean
- B.Character
- C.Array
- ✓ D.Integer
- E.Bit
Why A: Option A (Boolean) is correct because it is a primitive data type in most programming languages, representing a logical value of true or false (e.g., bool in C++/C#, boolean in Java). Option D (Integer) is correct because it is a fundamental primitive data type for whole numbers, implemented as int in Java/C#, integer in Pascal, or int in Python's numeric types. Option B (Character) is not marked correct because while char exists in many languages, it is not universally treated as a distinct primitive data type in all major languages (e.g., Python has no separate char type, using strings of length one). Option C (Array) is not marked correct because it is a composite or derived data structure, not a primitive data type in most languages. Option E (Bit) is not marked correct because bit is a unit of information rather than a standard primitive data type in most high-level programming languages.
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.