Kotlin - Null SafetyWhy does Kotlin allow platform types to be assigned to both nullable and non-nullable variables without compiler errors?ABecause Kotlin treats all Java types as nullable by defaultBBecause Kotlin trusts Java code and skips null checksCBecause platform types represent unknown nullability from JavaDBecause Kotlin disables null safety for Java interopCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand platform type conceptPlatform types represent Java types with unknown nullability.Step 2: Kotlin's flexible assignment rulesKotlin allows assigning platform types to nullable or non-nullable variables because it cannot be sure if null is possible.Final Answer:Because platform types represent unknown nullability from Java -> Option CQuick Check:Platform types = unknown nullability from Java [OK]Quick Trick: Platform types mean Kotlin can't infer Java nullability [OK]Common Mistakes:MISTAKESThinking Kotlin disables null safetyAssuming all Java types are nullableBelieving Kotlin trusts Java blindly
Master "Null Safety" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Array creation and usage - Quiz 2easy Collections Fundamentals - Collection size and emptiness checks - Quiz 14medium Data Types - Number literal formats (underscore, hex, binary) - Quiz 5medium Functions - Infix functions for readable calls - Quiz 8hard Kotlin Basics and JVM Runtime - Print and println output - Quiz 2easy Loops and Ranges - Why ranges simplify iteration - Quiz 1easy Loops and Ranges - Labeled break and continue - Quiz 9hard Null Safety - Safe call operator (?.) - Quiz 8hard Operators and Expressions - Operator precedence - Quiz 8hard Variables and Type System - Val for immutable references - Quiz 6medium