Kotlin - Data TypesWhat is wrong with this Kotlin code?val ch: Char = 65AChar can hold Int values directlyB65 is a valid Char literalCCannot assign Int directly to Char without conversionDCode compiles without errorCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand type assignment rulesKotlin does not allow assigning an Int directly to a Char variable.Step 2: Identify required conversionTo assign 65 as a Char, you must convert it using 65.toChar().Final Answer:Cannot assign Int directly to Char without conversion -> Option CQuick Check:Int to Char needs explicit conversion [OK]Quick Trick: Use toChar() to convert Int to Char explicitly [OK]Common Mistakes:MISTAKESAssigning Int directly to CharAssuming implicit conversion happensExpecting code to compile without error
Master "Data Types" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Array creation and usage - Quiz 13medium Data Types - Type conversion is always explicit - Quiz 8hard Data Types - Boolean type and logical operators - Quiz 2easy Kotlin Basics and JVM Runtime - What is Kotlin - Quiz 6medium Kotlin Basics and JVM Runtime - What is Kotlin - Quiz 14medium Kotlin Basics and JVM Runtime - Why Kotlin over Java - Quiz 9hard Loops and Ranges - Labeled break and continue - Quiz 10hard Null Safety - Safe casts with as? - Quiz 2easy Operators and Expressions - Equality (== structural vs === referential) - Quiz 9hard Operators and Expressions - Operator precedence - Quiz 15hard