CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Interface as a contract — methods, properties, and default implementations

    Kotlin SELF
    Level 37, Lesson 0
    We break down an interface in Kotlin as a contract: what exactly a class “promises” when it writes : SomeInterface, how fun methods work with no body and with a default implementation, why val/ var properties in an interface are not “storage fields”, and how to write reusable functions that accept an interface type (for example, CliPrintable) instead of concrete classes. Inside — practical examples with Identifiable, Greeter, RenderableLine and HasTitle, plus a walkthrough of typical mistakes.
    Available
  • Multiple interface implementation

    Kotlin SELF
    Level 37, Lesson 1
    We break down multiple interface implementation in Kotlin: why it’s better to keep interfaces narrow, how Kotlin forbids ambiguity when implementations conflict, when override is mandatory, and how to explicitly choose the needed implementation via super<...>. Using examples, we’ll show conflicts of default methods, the combination of a default + an abstract declaration, conflicts between a base class and an interface, as well as similar situations with properties ( val).
    Available
  • fun interface and SAM conversion

    Kotlin SELF
    Level 37, Lesson 2
    Let’s break down why Kotlin needs fun interface, what SAM conversion is, and how the compiler “turns” a lambda into an interface object. We’ll compare a SAM interface with functional types ( ( Int ) -> Boolean) and typealias, build a registry of CLI commands via CommandHandler, discuss closures, and go over common mistakes (two abstract functions, signature mismatch, hidden mutability).
    Available
  • sealed interface — a closed set of variants

    Kotlin SELF
    Level 37, Lesson 3
    We break down how sealed interface helps model a “closed set of variants” instead of strings, flags, and null. We learn how to parse input into the Command type, write an exhaustive when without else, introduce an execution result via CommandResult ( Ok/ Error), and also look at the nuances of choosing between enum, sealed class, and sealed interface.
    Available
  • object, companion object, object : ... — singleton and one-off objects

    Kotlin SELF
    Level 37, Lesson 4
    We break down three object forms in Kotlin: a named singleton via object, a “nearly static” API via companion object, and one-off implementations via object : Interface { ... }. Along the way, we’ll discuss where to store constants and factories, how not to turn a singleton into a “global junk drawer”, and why an anonymous object can “lose” its unique methods because of the variable’s static type.
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym