Skip to content

A single-file Kotlin project showcasing all core OOP concepts abstraction, encapsulation, inheritance, and polymorphism along with data classes, enum classes, sealed classes, generics, companion objects, singletons, delegation, and extension functions, with runnable examples.

Notifications You must be signed in to change notification settings

Ramana1357/OOP_main_concepts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

OOP_main_concepts

A single-file Kotlin project showcasing all core OOP concepts abstraction, encapsulation, inheritance, and polymorphism along with data classes, enum classes, sealed classes, generics, companion objects, singletons, delegation, and extension functions, with runnable examples.

Kotlin OOP Illustrated Guide πŸš€

This repository is a one-file Kotlin project that demonstrates the core concepts of Object-Oriented Programming (OOP) using idiomatic Kotlin features.
The code is heavily commented and designed to be self-explanatory for learners.


✨ Concepts Covered

  • Abstraction β†’ Interfaces & Abstract classes
  • Encapsulation β†’ Private/protected fields with controlled access
  • Inheritance & Polymorphism β†’ Open classes, overrides, and dynamic behavior
  • Data Classes & Enum Classes β†’ Idiomatic Kotlin modeling
  • Sealed Classes β†’ Exhaustive when usage
  • Generics & Delegation β†’ Reusable repository pattern
  • Singletons & Companion Objects β†’ object keyword and static-like members
  • Extension Functions β†’ Cleaner functionality extension
  • Error Handling β†’ Safe validations with require and exceptions

πŸ› οΈ How to Run

  1. Clone the repo:

    git clone https://github.com/your-username/kotlin-oop-guide.git
    cd kotlin-oop-guide
  2. Compile and run with Kotlin (ensure you have the Kotlin compiler installed):

    kotlinc Main.kt -include-runtime -d oop-demo.jar
    java -jar oop-demo.jar
  3. You’ll see console output demonstrating each OOP concept in action.


πŸ“‚ File Structure

.
β”œβ”€β”€ Main.kt    # Single Kotlin file with OOP examples
└── README.md  # This documentation

πŸ“Έ Sample Output

=== ENUM ===
Role=MODERATOR, canApprove=true

=== INHERITANCE + POLYMORPHISM ===
Manager Asha is planning and reviewing (0 reports)
Intern Ravi is learning and assisting
...

πŸ“š Learning Goal

This project is intended as a study reference for B.Tech / CS students or anyone learning Kotlin OOP.
It’s a quick way to see all major OOP principles in one place.


🏷 License

This project is open-source .

About

A single-file Kotlin project showcasing all core OOP concepts abstraction, encapsulation, inheritance, and polymorphism along with data classes, enum classes, sealed classes, generics, companion objects, singletons, delegation, and extension functions, with runnable examples.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages