โœ•
โœ๏ธ Content byMd. Rakibul Islam
๐ŸŽฏ
MCQ
Multiple Choice ยท 8 questions
1Easytypes vs interfacesโฑ 35s

What is the key difference between type and interface in TypeScript?

โ–ผ
2Easyany typeโฑ 30s

What does the 'any' type do in TypeScript?

โ–ผ
3Easyreturn typesโฑ 35s

What is the output type of this TypeScript function?

โ–ผ
typescript
function greet(name: string) {
  if (name.length > 5) {
    return 'Hello, ' + name;
  }
}
4Easyoptional propertiesโฑ 30s

What does the '?' (optional) operator do in a TypeScript interface?

โ–ผ
typescript
interface User {
  name: string;
  age?: number;
}
5Easyunknown vs anyโฑ 35s

What is the difference between 'unknown' and 'any' in TypeScript?

โ–ผ
6Easyreadonlyโฑ 40s

What does the 'readonly' modifier do in TypeScript?

โ–ผ
typescript
interface Config {
  readonly apiUrl: string;
  timeout: number;
}
const cfg: Config = { apiUrl: 'https://api.example.com', timeout: 5000 };
cfg.timeout = 3000; // ?
cfg.apiUrl = 'new';  // ?
7Easyunion typesโฑ 30s

What is a union type in TypeScript?

โ–ผ
typescript
function format(value: string | number): string {
  return String(value);
}
8Easytype assertionsโฑ 35s

What is a type assertion in TypeScript and when should you use it?

โ–ผ
typescript
const input = document.getElementById('name') as HTMLInputElement;
console.log(input.value);
Typescript MCQ Interview Questions โ€” All Levels | UyTech