• Courses
  • Tutorials
  • Practice
  • Contests
Switch to Dark Mode

TypeScript | Generics in TypeScript | Question4

Last Updated : Mar 22, 2025
Discuss
Comments

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;
    }
}


A

Box is a generic class where T can be replaced with a specific type.

B

T must always be a string in this class.

C

T is a built-in generic type.

D

The class is invalid because it uses <T>.

Share your thoughts in the comments