Levon Badalian
Quiz por , criado more than 1 year ago

Information Technology Quiz sobre Quiz: TypeScript. Interfaces and Classes., criado por Levon Badalian em 28-04-2017.

8
0
0
Levon Badalian
Criado por Levon Badalian mais de 7 anos atrás
Fechar

Quiz: TypeScript. Interfaces and Classes.

Questão 1 de 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.

Selecione uma ou mais das seguintes:

  • 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);

Explicação

Questão 2 de 3

1

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

Selecione uma ou mais das seguintes:

  • implements

  • inherits

  • super

  • base

  • extends

Explicação

Questão 3 de 3

1

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

Selecione uma ou mais das seguintes:

  • class implements interface

  • class extends interface

  • interface extends interface

  • interface extends class

  • interface implements class

  • interface implements interface

Explicação