Quiz: Subtyping

Take a short quiz on subtyping in plain JavaScript.

1

Which of the following JS code snippets correctly defines two classes A and B, where B is a subclass of A?

A)
class A {
  constructor (a) {
    this.propA = a;
  }
}
class B extends A {
  constructor (b) {
    this.propB = b;
  }
}
B)
class A {
  constructor (a) {
    this.propA = a;
  }
}
class B extends A {
  constructor (b) {
    super( b)
    this.propB = b;
  }
}
C)
class A {
  constructor (a) {
    this.propA = a;
  }
}
class B extends A {
  constructor (a,b) {
    super( a)
    this.propB = b;
  }
}
D)
class A extends B {
  constructor (a) {
    this.propA = a;
  }
}
class B {
  constructor (a,b) {
    super( a)
    this.propB = b;
  }
}
Question 1 of 30 attempted

Get hands-on with 1400+ tech skills courses.