Kotlin - Null SafetyWhich Kotlin collection type allows null elements by default?AList<String>BMutableList<String>CList<String?>DSet<String>Check Answer
Step-by-Step SolutionSolution:Step 1: Analyze the type declarationList and MutableList do not allow nulls because the type String is non-nullable.Step 2: Identify nullable type usageList explicitly allows null elements because the element type is nullable (String?).Final Answer:List allows null elements by default. -> Option CQuick Check:Nullable element type = allows nulls [OK]Quick Trick: Use ? after type to allow nulls in collections [OK]Common Mistakes:MISTAKESConfusing MutableList with nullabilityAssuming Set allows nulls by defaultIgnoring the ? in the element type
Master "Null Safety" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Collection size and emptiness checks - Quiz 14medium Collections Fundamentals - Mutable vs immutable interfaces - Quiz 1easy Control Flow as Expressions - When as expression returning value - Quiz 15hard Data Types - Number literal formats (underscore, hex, binary) - Quiz 14medium Functions - Single-expression functions - Quiz 6medium Functions - Named arguments for clarity - Quiz 1easy Kotlin Basics and JVM Runtime - What is Kotlin - Quiz 15hard Loops and Ranges - Repeat function for simple repetition - Quiz 3easy Loops and Ranges - While and do-while loops - Quiz 8hard Operators and Expressions - Operator precedence - Quiz 4medium