Search Header Logo

TypeScript basics 1

Authored by Artem Shamsutdinov

Computers

5th Grade - University

15 Questions

Used 32+ times

TypeScript basics 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How does a TypeScript class implement an interface?

class MyCoolClass implements IMyCoolInterface {

}

class MyCoolClass extends IMyCoolInterface {

}

interface IMyCoolInterface implemented by MyCoolClass {

}

A class implements an interface automatically.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

2) What is the benefit of interfaces?

They let you hide what the class is and reference an object via the interface.

They let you define inline-objects with type safety, like so:


let myObject: IMyCoolInterface = {

myCoolVariable: 1

}

They let you change assign a different class to a variable as long as it implements the same interface.

All of the above.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

TypeScript is all about specifying what type your variable or return value is. Is is possible to define

a variable in TypeScript without a type? Like so:


let a


and not:


let a: number

Yes type is optional (for interoperability with JavaScript)

No, type is always required (knowing types always helps prevent bugs)

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What type of variable is this:


var version: {

subVersion: number

};

boolean

number

object

string

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is a difference between the following:


let a = 0;

const a = 0;

"const a" can be reassigned. "let a" cannot be reassigned.

"let a" can be reassigned. "const a" cannot be reassigned.

There is no difference

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How do you declare a variable inside a class?

class MyCoolClass {

let myCoolVariable;

}

class MyCoolClass {

myCoolVariable;

}

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How do you declare a method inside a class?

class MyCoolClass {

function myCoolMethod() {

}

}

class MyCoolClass {

myCoolMethod() {

}

}

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?