Kotlin - Data TypesWhich of the following is the correct way to declare a Double variable with value 2.71828 in Kotlin?Aval e: Double = 2Bval e: Double = 2.71828Cval e: Double = 2.71828LDval e: Double = 2.71828fCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand Kotlin suffixes for number typesFloat literals use 'f', Long literals use 'L', Double literals have no suffix.Step 2: Choose the correct syntax for DoubleAssigning 2.71828 without suffix to a Double variable is correct.Final Answer:val e: Double = 2.71828 -> Option BQuick Check:Double literal = no suffix [OK]Quick Trick: Double literals have no suffix; Float uses 'f', Long uses 'L' [OK]Common Mistakes:MISTAKESAdding 'f' suffix to DoubleUsing 'L' suffix for decimalsAssigning integer without decimal to Double
Master "Data Types" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Accessing elements safely - Quiz 2easy Collections Fundamentals - List creation (listOf, mutableListOf) - Quiz 4medium Control Flow as Expressions - When with multiple conditions - Quiz 3easy Control Flow as Expressions - When as expression returning value - Quiz 8hard Functions - Unit return type - Quiz 5medium Functions - Parameters with default values - Quiz 6medium Loops and Ranges - For loop with index (withIndex) - Quiz 14medium Null Safety - Nullable types with ? suffix - Quiz 13medium Operators and Expressions - Logical operators (&&, ||, !) - Quiz 12easy Variables and Type System - Why immutability by default matters - Quiz 6medium