Levon Badalian
Quiz by , created more than 1 year ago

Information Technology Quiz on Quiz: TypeScript. Interfaces and Classes., created by Levon Badalian on 28/04/2017.

7
0
0
Levon Badalian
Created by Levon Badalian about 7 years ago
Close

Quiz: TypeScript. Interfaces and Classes.

Question 1 of 3

1

Consider the following interface and function:

interface Person {
readonly firstname: string;
middlename?: string;
surname: string;
}

function getFullName(p: Person): string {
if (p.middlename !== null && p.middlename !== undefined)
{
if (p.firstname !== null && p.firstname !== undefined)
{
return `${p.firstname} ${p.middlename} ${p.surname}`;
}
else
{
return `${p.middlename} ${p.surname}`;
}
}
else
{
return `${p.firstname} ${p.surname}`;
}
}

Which of the following code snippets will output "John Doe"? Select all that apply.

Select one or more of the following:

  • let fullname = getFullName({ title: "Mr", firstname: "John", surname: "Doe" });
    console.info(fullname);

  • let myName = { title: "Mr", firstname: "John", surname: "Doe" }
    let fullname = getFullName(myName);
    console.info(fullname);

  • let myName: Person = { firstname:"Johnathan", surname: "Doe" }
    myName.firstname = "John";
    let fullname = getFullName(myName);
    console.info(fullname);

  • let myName: Person = { middlename:"John", surname: "Doe" }
    let fullname = getFullName(myName);
    console.info(fullname);

Explanation

Question 2 of 3

1

Which of the following keywords can be used in TypeScript to implement interface and inheritance. Choose all that appy.

Select one or more of the following:

  • implements

  • inherits

  • super

  • base

  • extends

Explanation

Question 3 of 3

1

Which of the following is possible to do in TypeScript? Choose all that apply.

Select one or more of the following:

  • class implements interface

  • class extends interface

  • interface extends interface

  • interface extends class

  • interface implements class

  • interface implements interface

Explanation