Git Product home page Git Product logo

fewpjs-oo-reviewing-javascript-inheritance-quiz-nyc-web-062419's Introduction

Quiz: Reviewing JavaScript Inheritance

???

Reviewing JavaScript Inheritance

?:

class Animal {
  constructor(name) {
    this.name = name;
  }
  eats() {
    return `${this.name} is eating!`
  }
}
class Mammal {
  constructor(name) {
    this.name = name;
  }
  sleeps() {
    return `${this.name} is sleeping!`
  }
}
class Rabbit extends Mammal {
  //...
} 
let animal = new Animal("Ringo");
let mammal = new Mammal("Wilbur");
let rabbit = new Rabbit("Jabby");

Which function will not output โ€œ[Name] is sleeping!โ€

( ) None of the above ( ) mammal.sleeps() (X) animal.sleeps() ( ) rabbit.sleeps()

?: The accepted functionality of extend is to build new functionality into the inherited method:

( ) True (X) False

?:

class Animal {
  constructor(name) {
    this.name = name;
  }
  eats() {
    return `${this.name} is eating!`
  }
}
class Rabbit extends Mammal {
  constructor(name, color) {
    //..
  }
}

What is the correct way to have the constructor for rabbit inherit the name property?

( ) this.name = name; (X) super(name); ( ) this.name = super(name); ( ) super(name) = name;

?: What keyword does JavaScript provide for directly working with a parent class constructor and inherited methods?

(X) super ( ) extends ( ) class ( ) constructor

?:

class Vehicle {
  constructor( make ) {
    this._make = make
  }

  get make() {
    return this._make
  }

 static definition() {
    return 'A vehicle is used for transporting people or goods, especially on land.'
  }
}

class Car extends Vehicle {
  constructor( make , driveTrain ) {
    super( make )
    this._driveTrain = driveTrain
  }

  static definition() {
    return `${super.definition()} A car is a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people.`
  }
}

What is the correct way to have the car utilize the inherited static method of definition?

( ) ${definition()} a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people. ( ) ${this.definition()} a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people. ( ) ${super.definition()} + a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people. (X) ${super.definition()} a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people.

???

fewpjs-oo-reviewing-javascript-inheritance-quiz-nyc-web-062419's People

Contributors

drakeltheryuujin avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.