7. Quiz Questions

7.1. Question 1: Collection-valued properties

Which of the following statements about implementing collection-valued properties in JS are correct? Select one or more:

  1. ☐ A bag-valued property is implemented by representing bags (also called 'multi-sets') as JS arrays.

  2. ☐ A set-valued property is preferably implemented by representing sets as JS arrays since, as opposed to JS maps, they guarantee that each element is unique.

  3. ☐ An ordered-set-valued property is implemented by representing ordered sets as JS maps.

  4. ☐ An ordered-set-valued property is implemented by representing ordered sets as JS arrays.

  5. ☐ A set-valued property is preferably implemented by representing sets as classical JS maps since, as opposed to JS arrays, they guarantee that each element is unique.

  6. ☐ A bag-valued property is implemented by representing bags (also called 'multi-sets') as JS maps.

7.2. Question 2: Implementing the CASCADE deletion policy

Making the assumption that books existentially depend on their authors, implying a CASCADE deletion policy, which of the following Author.destroy methods correctly implements the implied deletion policy? Select one:

  1. O

    Author.destroy = function (authorId) {
      for (const isbn of Object.keys( Book.instances)) {
        const book = Book.instances[isbn];
        if (authorId in book.authors) delete book.authors[authorId];
      }
      delete Author.instances[authorId];
    };
  2. O

    Author.destroy = function (authorId) {
      for (const isbn of Object.keys( Book.instances)) {
        const book = Book.instances[isbn];
        if (authorId in book.authors) book.authors[authorId] = null;
      }
      delete Author.instances[authorId];
    };
  3. O

    Author.destroy = function (authorId) {
      for (const isbn of Object.keys( Book.instances)) {
        const book = Book.instances[isbn];
        if (authorId in book.authors) delete Book.instances[isbn];
      }
      delete Author.instances[authorId];
    };

7.3. Question 3: JS class model

Which is the correct JS class model for the Committee class derived from the given OO class model?

Select one:

  1. O

  2. O

  3. O