Skip to content

Machine Coding (OOP)

Machine coding rounds test your ability to design and implement OOP systems. You’re given a problem and expected to create a clean, extensible class design with proper OOP principles.


  1. Understand Requirements — What are the core features?
  2. Identify Key Entities — Nouns = potential classes
  3. Define Relationships — IS-A (inheritance), HAS-A (composition/aggregation)
  4. Create Class Diagram — Properties, Methods, Relationships
  5. Write Code — Implement with proper OOP principles
  6. Test with Scenarios — Verify main use cases

  • ParkingLot — Manages floors and tickets
  • ParkingFloor — Contains parking spots
  • ParkingSpot — Individual spot (Small/Medium/Large)
  • Vehicle — Bike, Car, Truck
  • Ticket — Records entry/exit and calculates fee

  • ATM — Machine with card reader and cash dispenser
  • BankAccount — Encapsulated balance
  • Session — Tracks authentication
  • Transaction — Records operations

TipDescription
Start with entitiesIdentify nouns as potential classes
Define relationshipsIS-A, HAS-A associations
Use encapsulationPrivate fields, public methods
Think extensibilityCan you add new types without modifying core?
Handle errorsInvalid inputs, edge cases

Previous Topic: Real-World Examples → Next Topic: Interview Questions →