Swift - Data TypesWhat is wrong with this Swift code snippet?let letter: Character = "Hello"AThe variable name 'letter' is a reserved keyword.BA Character can only hold a single character, not a string.CCharacter type cannot be assigned using double quotes.DThe code is correct and will compile without errors.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand Character typeIn Swift, a Character represents a single extended grapheme cluster, which means it can hold exactly one visible character.Step 2: Analyze the assignmentThe code attempts to assign "Hello" (a string of multiple characters) to a Character variable, which is invalid.Final Answer:A Character can only hold a single character, not a string. -> Option BQuick Check:Assigning multiple characters to Character type causes a compile-time error. [OK]Quick Trick: Character holds one character only. [OK]Common Mistakes:Thinking Character can hold multiple characters like String.Using double quotes incorrectly for Character.Assuming variable names like 'letter' are reserved.
Master "Data Types" in Swift9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Swift Quizzes Collections - Array operations (append, insert, remove) - Quiz 7medium Collections - Array creation and type inference - Quiz 7medium Data Types - Bool type and logical operators - Quiz 2easy Functions - Functions returning tuples - Quiz 13medium Loops - Repeat-while loop - Quiz 12easy Optionals - Multiple optional binding - Quiz 7medium Optionals - Guard let for early exit - Quiz 1easy Optionals - Force unwrapping with ! and its danger - Quiz 12easy Swift Basics and Runtime - Main entry point and @main attribute - Quiz 3easy Variables and Constants - Var for variables (mutable) - Quiz 5medium