Which of the following defines a generic class?
class Box<T> {
private content: T;
constructor(content: T) {
this.content = content;
}
getContent(): T {
return this.content;
}
}
Box is a generic class where T can be replaced with a specific type.
T must always be a string in this class.
T is a built-in generic type.
The class is invalid because it uses <T>.
This question is part of this quiz :
Generics in TypeScript QuizTypeScript | Generics in TypeScript | Question4