Connect 4 Techs
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact
No Result
View All Result
Connect 4 Techs
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact
No Result
View All Result
Connect 4 Techs
No Result
View All Result
Home Kotlin

Kotlin Class Functions & Inheritance (Lesson 13 PDF)

Ahmed Elhozayen by Ahmed Elhozayen
October 11, 2026
in Kotlin
0
Kotlin Class Functions & Inheritance (Lesson 13 PDF)

Kotlin is a statically typed programming language that runs on the Java Virtual Machine (JVM). It was developed by JetBrains and is now an official language for Android development. Kotlin is designed to be concise, expressive, and safe. It is also interoperable with Java, which means that you can use Kotlin and Java code together in the same project.

Kotlin

You might also like

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)

Kotlin Functions & Classes (Lesson 11 PDF)

Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)

Kotlin Class Functions & Inheritance (Lesson 13 PDF)

Overview about the Lesson

In this lesson, we will cover the following topics:

  • How to declare and call class functions in Kotlin
  • How to use the this keyword to refer to the current instance of a class
  • How to override class functions and use the super keyword to access the parent class function
  • How to define and use abstract classes and functions in Kotlin
  • How to implement interfaces and multiple inheritance in Kotlin
  • How to use the open, final, sealed and data modifiers for classes and functions

The Content of the Lesson

The lesson consists of a PDF file that contains the theory and examples of each topic, as well as exercises and solutions for you to practice. You can download the PDF file from the link at the end of this post. You can also watch the video lecture that accompanies the lesson on our YouTube channel.

Why This Lesson

This lesson is important because it will help you understand how to create and use classes and functions in Kotlin, which are essential for developing any kind of application.

You will also learn how to use inheritance and interfaces to achieve polymorphism, which is the ability of an object to behave differently depending on its type. This will make your code more flexible and extensible.

Kotlin Inheritance, Overriding and Interfaces: Examples

The PDF covers class functions and inheritance. Here are the essentials with runnable code and the output to expect.

Classes are final by default

In Kotlin, a class cannot be inherited unless you mark it open. The same applies to its functions. This “closed by default” design prevents accidental, fragile inheritance.

open class Animal(val name: String) {
    open fun sound() = "..."
    fun describe() = "$name says ${sound()}"
}

class Dog(name: String) : Animal(name) {
    override fun sound() = "Woof"
}

class Cat(name: String) : Animal(name) {
    override fun sound() = "Meow"
}

fun main() {
    val pets: List<Animal> = listOf(Dog("Rex"), Cat("Misty"))
    for (p in pets) println(p.describe())
}
// Output:
// Rex says Woof
// Misty says Meow

This is polymorphism: describe() is written once in the parent, but each subclass supplies its own sound().

Calling the parent implementation with super

open class Employee(val name: String) {
    open fun bonus() = 1000
}

class Manager(name: String) : Employee(name) {
    override fun bonus() = super.bonus() + 500
}

fun main() {
    println(Manager("Hana").bonus())   // 1500
}

Abstract classes

abstract class Shape {
    abstract fun area(): Double
    fun report() = "Area: ${"%.2f".format(area())}"
}

class Circle(val r: Double) : Shape() {
    override fun area() = Math.PI * r * r
}

fun main() {
    println(Circle(2.0).report())   // Area: 12.57
}

An abstract class cannot be created directly; it defines what subclasses must implement.

Interfaces

interface Drivable {
    fun drive(): String
    fun honk() = "Beep!"        // interfaces can have default implementations
}

interface Electric {
    fun charge() = "Charging..."
}

class Tesla : Drivable, Electric {
    override fun drive() = "Driving silently"
}

fun main() {
    val t = Tesla()
    println(t.drive())   // Driving silently
    println(t.honk())    // Beep!
    println(t.charge())  // Charging...
}

A class can extend only one class but implement many interfaces.

Abstract class or interface?

Use…When
An interfaceYou want to describe a capability that unrelated classes can share (Drivable, Printable)
An abstract classSubclasses share state (properties with values) and common code
An open classThe parent is useful on its own but can be specialised

Practice exercise

Create an open class Account with a function fee() returning 10, and a PremiumAccount that overrides it to return 0.

open class Account {
    open fun fee() = 10
}

class PremiumAccount : Account() {
    override fun fee() = 0
}

fun main() {
    println(Account().fee())          // 10
    println(PremiumAccount().fee())   // 0
}

Frequently Asked Questions

Why do I get “This type is final, so it cannot be inherited from”?

Because Kotlin classes are final by default. Add open before class in the parent, and open before every function you want to override.

What is the root class of all Kotlin classes?

Any. Every class inherits equals(), hashCode() and toString() from it.

Continue the course

← Previous: Lesson 12: Classes, Objects & Constructors

  1. Lesson 1: Getting Started
  2. Lesson 2: Syntax & Output
  3. Lesson 3: Comments & Variables
  4. Lesson 4: Data Types
  5. Lesson 5: Operators
  6. Lesson 6: Set Operations & Grouping
  7. Lesson 7: Booleans & If…Else
  8. Lesson 8: When, While, Break & Continue
  9. Lesson 9: Arrays
  10. Lesson 10: For Loops & Ranges
  11. Lesson 11: Functions & Classes
  12. Lesson 12: Classes, Objects & Constructors
  13. Lesson 13: Class Functions & Inheritance (you are here)

Conclusion

We hope you enjoy this lesson and find it useful for your learning journey. Kotlin is a powerful and expressive language that offers many features and benefits for developers. By learning how to use class functions and inheritance, you will be able to create more complex and sophisticated programs with Kotlin.

Download from Link

You can download the lesson from the following link:

From Here

Tags: AndroidJavaJVMKotlinProgrammingtechnology
Previous Post

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)

Next Post

iPad 2024: What We Want and What to Expect

Ahmed Elhozayen

Ahmed Elhozayen

Related Posts

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)
Kotlin

Kotlin Classes and Objects & Constructors (Lesson 12 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin Functions & Classes (Lesson 11 PDF)
Kotlin

Kotlin Functions & Classes (Lesson 11 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)
Kotlin

Kotlin For Loop & Kotlin Ranges (Lesson 10 PDF)

by Ahmed Elhozayen
October 11, 2026
 Kotlin Arrays (Lesson 9 PDF)
Kotlin

 Kotlin Arrays (Lesson 9 PDF)

by Ahmed Elhozayen
October 11, 2026
Kotlin When & While Loop, Break & Continue (Lesson 8 PDF)
Kotlin

Kotlin When & While Loop, Break & Continue (Lesson 8 PDF)

by Ahmed Elhozayen
October 11, 2026
Next Post
iPad 2024: What We Want and What to Expect

iPad 2024: What We Want and What to Expect

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Microsoft Excel Formulas Cheat Sheet PDF

Microsoft Excel Formulas Cheat Sheet PDF

October 11, 2026
The Ultimate Excel Handbook v3 PDF

The Ultimate Excel Handbook V3 PDF

March 21, 2025

Categories

  • apple
  • Canon
  • Data Analysis
  • Excel
  • Finance
  • ios
  • Kotlin
  • Marketing
  • MBA
  • Samsung
  • Software Tutorials
  • Technology

Don't miss it

20 Essential Excel Formulas Every Data Analyst Must Know in 2026
Data Analysis

20 Essential Excel Formulas Every Data Analyst Must Know in 2026

May 18, 2026
Excel guide for data analytics learners
Excel

Excel for Data Analysis PDF

October 11, 2026
The Ultimate Guide to Financial Modeling PDF
Excel

The Ultimate Guide to Financial Modeling PDF

October 11, 2026
The Ultimate Excel Handbook PDF
Excel

The Ultimate Excel Handbook PDF

October 11, 2026
𝟓𝟎 𝐄𝐱𝐜𝐞𝐥 𝐒𝐡𝐨𝐫𝐭𝐜𝐮𝐭 𝐊𝐞𝐲
Excel

50 Excel Shortcut Key PDF: Streamline Your Workflow

March 21, 2025
Most Useful Excel Keyboard Shortcuts For Windows and Mac OS
Excel

Most Useful Excel Keyboard Shortcuts for Windows and Mac OS PDF

March 21, 2025
Connect4Techs Tech

Practical, free guides on Excel, data analysis, finance, business and programming — written to help you learn faster and work smarter.

Follow on Facebook

Topics

  • Excel
  • Kotlin
  • MBA
  • Finance
  • Data Analysis
  • Apple
  • Technology
  • Software Tutorials

Latest articles

  • 20 Essential Excel Formulas Every Data Analyst Must Know in 2026May 18, 2026
  • Excel for Data Analysis PDFAug 31, 2025
  • The Ultimate Guide to Financial Modeling PDFApr 19, 2025

Company

  • About us
  • Contact
  • Privacy Policy
  • Terms of Use
  • IT Certification PDFs
© 2026 Connect4Techs. All rights reserved. Privacy · Terms · Contact
No Result
View All Result
  • Home
  • Excel
  • Data Analysis
  • Finance
  • MBA
    • Marketing
  • Kotlin
  • Gadgets
    • Apple
    • Samsung
    • Canon
    • Tech News
  • About
  • Contact