🔗
Classes & OOP

implements Keyword

Classes Following a Contract
💡 implements, keyword, EK, "SIGNED, CONTRACT" jaisa, hai — CLASS, EXPLICITLY, PROMISE, karti, hai, ki, WOH, EK, INTERFACE, ke, SAARE, REQUIREMENTS, FULFILL, karegi — AGAR, KUCH, MISSING, hai, COMPILE-TIME, ERROR, AATA, hai.

implements, keyword, se, EK, class, EXPLICITLY, DECLARE, karti, hai, ki, WOH, EK, INTERFACE, ko, FOLLOW, karegi — TypeScript, VERIFY, karta hai, ki, SAARE, REQUIRED, properties/methods, IMPLEMENTED, HAIN.

EK, class, MULTIPLE, interfaces, implement, kar, sakti hai (comma-separated) — LEKIN, sirf, EK, class, se, extend, kar, sakti, hai (SINGLE, INHERITANCE).

interface Flyable {
  fly(): void;
}
interface Swimmable {
  swim(): void;
}

class Duck implements Flyable, Swimmable {
  fly(): void { console.log("Flying..."); }
  swim(): void { console.log("Swimming..."); }
}
🔗
implements, keyword, EK, "SIGNED, CONTRACT" jaisa, hai — CLASS, EXPLICITLY, PROMISE, karti, hai, ki, WOH, EK, INTERFACE, ke, SAARE, REQUIREMENTS, FULFILL, karegi — AGAR, KUCH, MISSING, hai, COMPILE-TIME, ERROR, AATA, hai.
1 / 2
⚡ झट से Recap
  • implements = class, explicitly, ek, interface, ko, follow, karne, ka, promise, karti, hai
  • Multiple interfaces, implement, ki, ja, sakti, HAIN — sirf, EK, class, se, extend
  • Compile-time, verification, hai — runtime, PAR, koi, extra, checking, nahi
इस page में (2 subtopics)

implements, sirf, TYPE-CHECKING, hai (SHAPE, verify, karta hai). extends, ACTUAL, inheritance, hai (IMPLEMENTATION, INHERIT, hoti, hai). Ek, class, MULTIPLE, interfaces, implement, kar, sakti, hai, LEKIN, sirf, EK, class, se, extend, kar, sakti, hai.

class Bird extends Animal implements Flyable {
  fly() { console.log("Flying"); }
}

Interfaces, EK, EXISTING, class, ki, INSTANCE, SHAPE, ko, bhi, DESCRIBE, kar, sakte, HAIN — class, keyword, se, banaya, EK, TYPE, automatically, EK, interface, ki, tarah, USE, ho, sakta hai.

💡Tip: class MyClass {}, se, banaya, TYPE, DIRECTLY, TYPE, annotation, mein, USE, ho, sakta, hai — jaise, function process(item: MyClass), koi, EXPLICIT, interface, DEFINE, kiye, bina.