Exploring Kotlin's Visibility Modifiers: Scope Rules for Top-Level, Class, and Module Declarations

Kotlin provides four visibility modifiers: private, protected, internal, and public. The default visibility, when no modifier is explicitly applied, is public. Top-level declarations—such as functions, properties, classes, objects, and interfaces—live direct within a package: // File name: utils.kt package com.sample.utils // Visibility rules ...

Posted on Thu, 23 Jul 2026 16:52:14 +0000 by elementaluk

Kotlin Classes and Inheritance Fundamentals

Class Definition Kotlin uses the class keyword to declare classes. A class declaration consists of a name, an optional class header (specifying type parameters, primary constructor, etc.), and a class body enclosed in curly braces. Both the header and body are optional; if a class has no body, you can omit the curly braces. // Simple class defi ...

Posted on Sat, 09 May 2026 20:23:40 +0000 by creet0n