🏗️ Classes & Objects
3 exercises — read class definitions and choose the most professional, accurate English description. Covers constructor patterns, inheritance, and generics.
0 / 3 completed
OOP description vocabulary
- "This class is responsible for managing / storing / handling…"
- "[ChildClass] extends / inherits from [ParentClass]."
- "It overrides the [method] from the parent class."
- "The constructor initialises the [property] to [value]."
- "This is a generic class — it works with any type T."
1 / 3
Read this class definition. Which description is the most accurate?
class EventEmitter {
constructor() {
this.listeners = {};
}
on(event, callback) {
if (!this.listeners[event]) this.listeners[event] = [];
this.listeners[event].push(callback);
}
emit(event, ...args) {
(this.listeners[event] || []).forEach(cb => cb(...args));
}
off(event, callback) {
this.listeners[event] = (this.listeners[event] || []).filter(cb => cb !== callback);
}
}Option B is the most professional and complete description. It names the design pattern (publish-subscribe), explains what each capability does in natural English, and describes the use case. Option A accurately describes the implementation but misses the higher-level purpose. Option C is a structural list, not a description — just enumerating methods without explaining what they do together. Option D is partially correct but still too implementation-focused. In technical English, always try to answer: "What is this responsible for?" and "When would you use it?"