Levon Badalian
Quiz von , erstellt am more than 1 year ago

Information Technology Quiz am Quiz: TypeScript. Interfaces and Classes., erstellt von Levon Badalian am 28/04/2017.

8
0
0
Levon Badalian
Erstellt von Levon Badalian vor mehr als 7 Jahre
Schließen

Quiz: TypeScript. Interfaces and Classes.

Frage 1 von 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.

Wähle eine oder mehr der folgenden:

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

Erklärung

Frage 2 von 3

1

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

Wähle eine oder mehr der folgenden:

  • implements

  • inherits

  • super

  • base

  • extends

Erklärung

Frage 3 von 3

1

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

Wähle eine oder mehr der folgenden:

  • class implements interface

  • class extends interface

  • interface extends interface

  • interface extends class

  • interface implements class

  • interface implements interface

Erklärung