LAUNCH SALE 50% off every pass

See plans →

Module 1 School guide

Classes, objects and relationships

Build objects with valid state, clear responsibilities and methods that protect their data.

Lessons
6 · 1 h 45 min
Problems
3
Getting started
Core
SDE-1
Core
SDE-2
Recommended
Plan
Free

Lessons

Lesson 1 15 min School guide

Classes, objects and state

  • Use a wallet to see how an object stores data and controls changes to it. Its balance is state; pay() is behaviour.
  • Use a constructor to set a valid starting balance.
  • Keep the balance private. Change it through methods that reject invalid payments.
  • Distinguish a field shared by the class from a field stored separately in each wallet.
classobjectconstructoraccess modifierstatic
Lesson 2 20 min School guide

The four pillars without the textbook

  • Encapsulation: the wallet guards its own balance and exposes only the actions that keep it valid.
  • Abstraction: callers see pay(amount, toVpa) and none of the bank calls behind it.
  • Inheritance: an is-a relationship. Using it only to reuse code is a common reviewer flag.
  • Polymorphism: one call, different behaviour. Overloading is decided at compile time, overriding at runtime.
  • Explain each concept with a definition, an example and a limitation.
encapsulationabstractioninheritancepolymorphism
Lesson 3 20 min School guide

Interfaces, abstract classes and composition

  • An interface is a contract: PaymentMethod with pay(). An abstract class is a contract plus shared code.
  • Pick an interface when unrelated classes share a capability; pick an abstract class when siblings share real code.
  • Composition over inheritance: an Order has a PricingPolicy, so the policy can change at runtime.
  • UPI, card and BNPL as PaymentMethod implementations. Adding netbanking touches no existing class.
  • Syntax in each language: Java interface and default methods, C++ pure virtual functions, Python abc.
interfaceabstract classcompositionhas-ais-a
Lesson 4 15 min School guide

Polymorphism under the hood

  • C++: virtual functions, the vtable idea, object slicing when you pass by value, and why base classes need a virtual destructor.
  • Java: every non-final, non-static method dispatches at runtime. final and static change that.
  • Python: duck typing, so the interface is whatever methods you call.
  • Work through five code snippets and explain their output step by step.
virtual functionvtableobject slicingdynamic dispatchduck typing
Lesson 5 20 min School guide

Class relationships and UML class diagrams

  • Association, aggregation, composition and dependency, all shown on one parking lot.
  • Multiplicity: one lot has many floors, one ticket belongs to one vehicle.
  • Draw only what helps: class name, key fields, key methods, the arrows. Keep it to about five minutes.
  • Reading your diagram out loud, top to bottom, is a big part of an LLD round. Practice saying it.
  • Flipkart's 2026 SDE-2 review ended with a request to sketch the UML class diagram of the code just written. Be ready to draw it from code.
associationaggregationcompositiondependencymultiplicity
Lesson 6 15 min School guide

Enums, value objects and exceptions

  • Enums for fixed sets like VehicleType and OrderStatus. Raw strings let typos compile.
  • Money as a value object holding paise in a long. 0.1 + 0.2 is not 0.3 in floating point, so totals drift by paise.
  • equals and hashCode (or __eq__ and __hash__) whenever objects become map keys.
  • Custom exceptions like InsufficientBalanceException instead of returning -1. Flipkart's 2026 reviewers threw edge cases at the running code and expected no unexpected exception.
enumvalue objectimmutabilitycustom exception

Problems

Esc
↑↓Move ↵Open Ctrl↵New tab >Actions ?Shortcuts

Keyboard shortcuts

Anywhere

Open search
CtrlKor /
Show these shortcuts
?
Close a window or menu
Esc

In search

Move through results
↑or ↓
Open the result
↵
Open in a new tab, or a problem on its judge
Ctrl↵
List actions only
>
Remove the filter
⌫

Go to

Learn
GthenL
Practice
GthenP
Assessments
GthenA
System design
GthenS
Companies
GthenC
My profile
GthenM
Today's quest
GthenT
Home
GthenH

Report a bug

Page