Bird
0
0

Which of the following statements about Swift's String type is true?

easy📝 Conceptual Q1 of 15
Swift - Data Types
Which of the following statements about Swift's String type is true?
AStrings can only contain ASCII characters.
BStrings in Swift are collections of <code>Character</code> values.
CStrings are immutable and cannot be changed after creation.
DStrings must always be declared using the <code>var</code> keyword.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the nature of Swift strings

    Swift String is a collection type that holds multiple Character values, allowing it to represent text.
  2. Step 2: Evaluate each option

    Strings in Swift are collections of Character values. correctly states that strings are collections of characters. Strings can only contain ASCII characters. is false because Swift strings support Unicode, not just ASCII. Strings are immutable and cannot be changed after creation. is false because strings declared with var are mutable. Strings must always be declared using the var keyword. is false because strings can be declared with let (immutable) or var (mutable).
  3. Final Answer:

    Strings in Swift are collections of Character values. -> Option B
  4. Quick Check:

    String type = Collection of Characters [OK]
Quick Trick: Strings hold characters; think of a word as letters in a row [OK]
Common Mistakes:
  • Thinking strings only hold ASCII characters
  • Assuming all strings are immutable
  • Confusing let and var usage for strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes