Recall & Review
beginner
What does the public visibility modifier mean in Kotlin?
The public modifier means the declaration is visible everywhere. It is the default visibility if no modifier is specified.
Click to reveal answer
beginner
Explain the private visibility modifier in Kotlin.
The <strong>private</strong> modifier restricts the visibility to the containing class or file. It means the declaration cannot be accessed outside that scope.Click to reveal answer
intermediate
What does internal visibility mean in Kotlin?
internal means the declaration is visible everywhere in the same module but not outside it. A module is a set of Kotlin files compiled together.
Click to reveal answer
intermediate
Describe the protected visibility modifier in Kotlin.
<strong>protected</strong> means the declaration is visible in the class and its subclasses. It is not visible outside these classes, even if in the same package.Click to reveal answer
beginner
Which visibility modifier is the default in Kotlin if none is specified?
The default visibility modifier in Kotlin is public, meaning the declaration is visible everywhere.
Click to reveal answer
Which Kotlin visibility modifier allows access only within the same file?
✗ Incorrect
private restricts access to the containing file or class.
What does the internal modifier restrict visibility to?
✗ Incorrect
internal means visible within the same module.
Which modifier allows visibility in subclasses but not outside the class hierarchy?
✗ Incorrect
protected allows access in the class and its subclasses.
If no visibility modifier is specified in Kotlin, what is the default?
✗ Incorrect
The default visibility is public.
Can a private member be accessed from another file in the same module?
✗ Incorrect
private members are not accessible outside their file or class.
Describe the four visibility modifiers in Kotlin and give a simple example of when to use each.
Think about who should see your code: everyone, only inside, inside module, or subclasses.
You got /5 concepts.
Explain why you might choose internal over public for a Kotlin class.
Consider controlling access in bigger projects with multiple modules.
You got /4 concepts.