Kotlin - Data TypesWhat is the issue with the following Kotlin code?val binaryNum = 0b1102_1010AThe literal is missing a suffix like 'L' for LongBUnderscores are not allowed in binary literalsCBinary literals must start with '0x' instead of '0b'DBinary literals cannot contain the digit '2'Check Answer
Step-by-Step SolutionSolution:Step 1: Understand binary literal rulesBinary literals in Kotlin can only contain digits 0 and 1, optionally separated by underscores.Step 2: Identify invalid digitThe digit '2' is invalid in binary literals.Final Answer:Binary literals cannot contain the digit '2' -> Option DQuick Check:Check digits allowed in binary literals [OK]Quick Trick: Binary literals only use 0 and 1 digits [OK]Common Mistakes:MISTAKESUsing digits other than 0 or 1 in binary literalsConfusing binary prefix '0b' with hexadecimal '0x'Placing underscores at the start or end of the literal
Master "Data Types" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Mutable vs immutable interfaces - Quiz 2easy Control Flow as Expressions - If as an expression returning value - Quiz 8hard Control Flow as Expressions - When expression as powerful switch - Quiz 5medium Data Types - Nothing type for functions that never return - Quiz 14medium Kotlin Basics and JVM Runtime - What is Kotlin - Quiz 15hard Operators and Expressions - Arithmetic operators - Quiz 9hard Operators and Expressions - Arithmetic operators - Quiz 10hard Operators and Expressions - Why operators are functions in Kotlin - Quiz 9hard Variables and Type System - Val for immutable references - Quiz 10hard Variables and Type System - Var for mutable references - Quiz 14medium