Kotlin - FunctionsWhich statement about local functions in Kotlin is TRUE?ALocal functions must be declared outside any other function.BLocal functions can access variables from the outer function.CLocal functions cannot return values.DLocal functions are visible to other classes.Check Answer
Step-by-Step SolutionSolution:Step 1: Recall local function scopeLocal functions are nested inside other functions and can access variables from their outer function.Step 2: Evaluate each optionLocal functions are declared inside functions. Local functions can return values. Local functions are not visible outside their containing function.Final Answer:Local functions can access variables from the outer function. -> Option BQuick Check:Local functions access outer variables = True [OK]Quick Trick: Local functions see outer variables like a nested box [OK]Common Mistakes:MISTAKESThinking local functions are top-levelBelieving local functions cannot return anythingAssuming local functions are accessible outside their function
Master "Functions" in Kotlin9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kotlin Quizzes Collections Fundamentals - Array creation and usage - Quiz 8hard Control Flow as Expressions - When with ranges and types - Quiz 2easy Control Flow as Expressions - Smart casts in when and if - Quiz 12easy Data Types - Any type as universal base - Quiz 9hard Functions - Parameters with default values - Quiz 3easy Functions - Function declaration syntax - Quiz 13medium Loops and Ranges - For loop with ranges - Quiz 3easy Operators and Expressions - Range operator (..) and in operator - Quiz 9hard Variables and Type System - String templates and interpolation - Quiz 14medium Variables and Type System - Val for immutable references - Quiz 8hard