wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Typescript Basics

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

How would you describe Typescript as a programming language?

a)

Strongly Typed

b)

Weakly Typed

c)

Dynamically Typed

d)

Statistically Typed

2.

Which file extension is commonly used for TypeScript files?

a)

.js

b)

.tx

c)

.ts

d)

.tys

3.

TypeScript code is ultimately compiled into which language?

a)

C++

b)

Java

c)

Python

d)

JavaScript

4.

What command correctly represents build/compiling Typescript to JavaScript

a)

build

b)

tsc

c)

node tsc

d)

build tsc

5.

const student = 'Usman';

The implicit type here is a?

a)

Number

b)

String

c)

Boolean

d)

Object

6.

Which of the following correctly define an explicit type?

a)

let a = true

b)

let a: boolean = true

c)

let a = true:bolean

d)

let boolan: a = true

7.

At what time does checks in Typescripts occur?

a)

Run time

b)

Compile time

c)

Code time

d)

Dev Time

8.

Rasheed wants to create an array of only strings, which syntax should he use?

a)

names = [ ]

b)

names: any = [ ]

c)

names: string = [ ]

d)

names: string[] = [ ]

9.

Using this function:

const addNum = (num1: number, num2: number, num4?:number, num3: number = 10) => {}

num3 represents?

a)

Optional parameters

b)

Default parameters

c)

Return type

d)

None of the options

10.

Using this function:

const addNum = (num1: number, num2: number, num4?:number, num3: number = 10) => {}

num4 represents?

a)

Optional parameters

b)

Default parameters

c)

Return type

d)

None of the options

11.

Ella is creating a function to integrate data service providers(mtn, glo, etc). Which of the following concepts can help her define the different providers in her function

a)

Type alias

b)

Switch parameters

c)

Optional parameters

d)

Generics

12.

Which of the following is used to create a union type in TypeScript?

a)

&

b)

|

c)

~

d)

^

13.

What is the purpose of the "unknown" data type in TypeScript?

a)

Represents a variable that can have any type

b)

Represents a function that never returns

c)

Represents an object with an unknown structure

d)

There is no unkonwn

14.

How can you declare a generic type in TypeScript?

a)

Using the "generic" keyword

b)

Using the "type" keyword

c)

Using the "<>" syntax

d)

Using the "any" keyword

15.

A class can implement an interface

a)

True

b)

False

c)

How na??

d)

None of the options

16.

const createPerson = <T>(person: T) => ...

Which of the following is a correct way to use the above function

a)

createPerson('sam')

b)

createPerson(true)

c)

createPerson({

name: 'sam'

})

d)

All of the options

17.

enum Color {

Red,

Green,

Blue,

}

What is the value of blue?

a)

0

b)

1

c)

2

d)

3

18.

let x: [string, number];

What does this represent?

a)

Any Type

b)

Union Type

c)

Tuples

d)

Array Type

19.

Which of the following is not an access modifier

a)

Public

b)

Private

c)

Protected

d)

Readonly

e)

Static

20.

What is the purpose of the "typeof" operator in TypeScript?

a)

To check the type of a variable

b)

To define a new variable

c)

To create an instance of an object

d)

To import external modules