Quiz: Subtyping
Take a short quiz on subtyping in plain JavaScript.
We'll cover the following...
We'll cover the following...
Technical Quiz
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;
}
}
1 / 3