Understanding Object-Oriented Programming

Hello and welcome! In this lesson, we'll dive into Object-Oriented Programming (OOP). Object-Oriented Programming is a coding paradigm inspired by the real world. It envisages everything as an "Object" with certain properties (characteristics) and capabilities (methods). Take a football as an instance: it has properties like size and color and methods such as being able to be kicked or caught.

Exploring Kotlin Classes

A Class in Kotlin serves as a blueprint for creating objects. Using a Class, we essentially instruct Kotlin on the appearance and function of an object. We can declare a Class using the class keyword.

In this Class, we also define properties (characteristics) and methods (actions) that our object can have and perform. Check out this simple Football Class:

Creating Objects in Kotlin

An Object is a specific instance of a Class, built according to the blueprint we defined. To create an Object in Kotlin, we simply call the Class name:

So now, myFootball is an Object of the Football Class, possessing the properties and methods we defined in the Football Class.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal