Quiz on Using Inheritance
Test your knowledge of inheritance by taking this quiz.
1
The add()
method of Set
returns the instance of Set
with the added element. Let’s change
const set = new FunctionalSet(['Jack', 'Jill', 'Tom', 'Jerry']);
to:
const set = new FunctionalSet(['Jack', 'Jill', 'Tom', 'Jerry']) .add('Bill');
What change do we have to make in the FunctionalSet
class to make the add()
function work for this modified code?
class FunctionalSet extends Set {
}
A)
By defining the add()
method in FunctionalSet
B)
No change
C)
Making a derived class of FunctionalSet
and defining the add()
method in it.
Question 1 of 50 attempted
Get hands-on with 1400+ tech skills courses.