Find a course
Age level: University students (18–25)IntermediateTechnology & Programming

Object-Oriented Programming

Classes, encapsulation, inheritance, polymorphism and SOLID design

⏱ 2 h 40 min5 modules · 12 lessons82 practice questionsFinal exam: 20 questions
Included with this course

Your certificate for this course

Finish the 12 lessons (about 2 h 40 min) and pass the 20-question final exam. Your Certificate of Completion is ready the moment you pass.

  • Your name and this course titlePrinted in classic diploma typography
  • Grade: Pass, Merit or DistinctionOn the gold seal, with your final score
  • Unique ID and QR codeAnyone can verify it in seconds
  • Score report PDFModule-by-module results and exam score
  1. Lessons12 lessons
  2. Final exam20 questions · 70% to pass
  3. CertificatePDF + score report

What you will learn

  • Explain the four pillars of OOP and decide when an object-oriented design fits a problem
  • Write classes with constructors, methods, getters, static members and private fields in JavaScript, and read the Python equivalents
  • Predict how this is bound in JavaScript and fix the lost-this bug in callbacks
  • Protect invariants with encapsulation and design cohesive classes and immutable value objects
  • Use inheritance, method overriding and polymorphism correctly, and test hierarchies with the Liskov substitution principle
  • Choose between inheritance, composition, abstract classes and interfaces for a given design problem
  • Apply the SOLID principles and recognize the strategy, factory, observer, decorator, adapter and singleton patterns
  • Turn written requirements into a class model, read UML class diagrams and design classes that are easy to unit test

About this course

Most programs start small and then grow for years. Object-oriented programming (OOP) is the most widely used way of keeping that growth under control: you model a problem as objects that keep their own data and enforce their own rules, so one change doesn't ripple through the whole codebase.

This free course teaches OOP as a way of thinking, not just a set of keywords. You'll start with why objects exist at all, then write classes, constructors and methods, and learn exactly how this works and where it goes wrong. Next you'll protect object data with private fields and invariants, and design cohesive classes and immutable value objects.

The middle of the course covers the ideas people mean when they talk about OOP: inheritance with extends and super, polymorphism and dynamic dispatch, abstract classes, interfaces and the Liskov substitution principle. Then you'll learn why experienced designers often prefer composition over inheritance, and how the five SOLID principles keep code open to change. The final module covers the classic design patterns (strategy, factory, observer, decorator, adapter and singleton), turning requirements into a class model, reading UML class diagrams and designing objects that are easy to unit test.

Examples and coding challenges use JavaScript, which you can run right in your browser, with Python shown where the syntax differs. The concepts transfer directly to Java, C#, C++, Kotlin, Swift and TypeScript.

The course is for students and self-taught programmers who already know variables, functions, loops and arrays in at least one language and want to write larger programs well. Every lesson mixes short explanations with code challenges, bug hunts and design scenarios, and you can earn a free certificate of completion by passing the final exam.

Syllabus

  1. Thinking in Objects

    Model problems as objects with state and behavior, write classes and constructors, and master how this and static members work.

    1. Why Objects? From Loose Data to Models12 min
    2. Classes, Constructors and Instances14 min
    3. Methods, this and Static Members13 min
  2. Encapsulation and Class Design

    Protect object data with private fields and invariants, then design cohesive classes, value objects and clean public interfaces.

    1. Encapsulation: Private Data and Invariants14 min
    2. Designing Good Class Interfaces14 min
  3. Inheritance and Polymorphism

    Extend classes with inheritance, replace conditionals with polymorphism, and define reliable contracts with abstract classes and interfaces.

    1. Inheritance: Extending Classes14 min
    2. Polymorphism: One Call, Many Behaviors14 min
    3. Abstract Classes, Interfaces and Contracts14 min
  4. Composition and Design Principles

    Prefer composition over deep hierarchies and apply the SOLID principles to keep classes easy to extend, test and change.

    1. Composition Over Inheritance14 min
    2. The SOLID Principles15 min
  5. Patterns and Real-World Design

    Apply classic design patterns, model a system from requirements, read UML class diagrams and design objects that are easy to test.

    1. Classic Design Patterns15 min
    2. Modeling a System with Objects15 min
  6. Final exam and certificate

    20 questions drawn from a pool of 32. Score 70% or more to pass; retakes get a fresh set of questions.

Try a sample question

In OOP, a method is simply a function that is attached to an object and can work with that object's data.

True or false?

Show the answer

Answer: True

That is exactly what a method is. Inside it, a reference such as this (JavaScript, Java, C#) or self (Python) gives access to the object the method was called on, which is how one method can serve thousands of different objects.

Object
A bundle of state (fields) and behavior (methods) that represents one thing in a program.
Class
A blueprint that defines the fields and methods shared by a kind of object.
Instance
One concrete object created from a class.
Constructor
A special method that runs when an object is created and sets up its starting state.
Field
A variable that belongs to an object; also called a property or attribute.
Method
A function defined in a class that operates on an instance's data.

Frequently asked questions

What are the four pillars of object-oriented programming?

Encapsulation (hiding data behind methods), abstraction (working with what an object does rather than how), inheritance (building a class on top of another) and polymorphism (different objects responding to the same call in their own way). Many designers would add composition as an equally important tool.

Which language does this course use?

Code examples and challenges use JavaScript, because it runs in any browser with no setup. Python versions are shown where the syntax differs, and the concepts apply directly to Java, C#, C++, TypeScript, Kotlin and Swift.

Do I need to know JavaScript already?

You should know basic programming in some language: variables, functions, if statements, loops and arrays. If you have used Python or Java, you will be able to follow the JavaScript examples, since the course explains class syntax as it goes.

Is inheritance bad?

No, but it is the most overused OOP feature. Inheritance fits genuine, stable is-a relationships that pass the Liskov substitution test. For reusing code or combining features, composition is usually more flexible and less fragile.

Are SOLID principles and design patterns still relevant?

Yes. Languages and frameworks change, but the problems they address, code that is hard to change, test or extend, do not. Use them as guidelines for judgment rather than rules to apply everywhere, especially in small programs.

Is functional programming replacing OOP?

Most modern codebases mix both. Objects work well for things with identity and rules; pure functions work well for calculations and data transformations. Many ideas in this course, such as immutability and small focused units, are shared by both styles.

Is the certificate an accredited qualification?

No. It is a certificate of completion showing that you finished the lessons and passed the exam. It is a good way to show initiative on a profile, but it is not an academic credential.

Sources and further reading

Related courses

University studentsIntermediate

Data Structures and Algorithms

Big O, arrays, hash tables, trees, graphs, sorting and dynamic programming with hands-on code

Technology & Programming
2 h 40 min13 lessonsCertificate
University studentsBeginner

Introduction to Computer Science

Binary, hardware, algorithms, code and the internet: the ideas behind every computer

Technology & Programming
2 h 35 min12 lessonsCertificate
University studentsIntermediate

Operating Systems Concepts

Processes, threads, scheduling, memory, file systems and protection explained

Technology & Programming
2 h 50 min11 lessonsCertificate
University studentsBeginner

How Computers Work

From bits and logic gates to processors, memory and the operating system

Technology & Programming
2 h 25 min11 lessonsCertificate
TeensBeginner

Computer Science Principles

Data, algorithms, the internet and the impact of computing, the big ideas of CS

Technology & Programming
1 h 55 min11 lessonsCertificate
TeensBeginner

Binary and Number Systems

Count, convert and calculate in binary, hexadecimal and octal like a computer

Technology & Programming
1 h 50 min11 lessonsCertificate