CompTIA Tech+ (FC0-U71)Software Development ConceptsEasy

A developer is writing a program that needs to store a user's chosen difficulty level for a game. The difficulty can be 'Easy', 'Medium', or 'Hard'. Which of the following data types is most appropriate for storing this information?

  1. AFloat
  2. BInteger
  3. CString
  4. DBoolean
Show answer & explanation

Correct answer: C. String

The difficulty levels 'Easy', 'Medium', and 'Hard' are textual values. The String data type is specifically designed to store sequences of characters.

Why the other options are wrong

  • A. Float stores decimal numbers, not textual descriptions.
  • B. Integer stores whole numbers, not textual descriptions.
  • D. Boolean stores true/false values, not textual descriptions.

String Data Type

A data type used to represent text, which is a sequence of characters. Strings are typically enclosed in quotation marks.

  • Used for textual data like names, addresses, or messages.
  • Can contain letters, numbers, symbols, and spaces.
  • Often immutable in many programming languages, meaning their value cannot be changed after creation.

Memory trick: Strings are for words, just like a story is words.

More Software Development Concepts questions