4. Quiz Questions

4.1. Question 1: Defining a Subclass

Which of the following JavaScript code snippets correctly defines two classes A and B, such that B is a subclass of A? Select one:

  1. O

    class A {
      constructor (a) {
        this.propA = a;
      }
    }
    class B extends A {
      constructor (b) {
        this.propB = b;
      }
    }
  2. O

    class A {
      constructor (a) {
        this.propA = a;
      }
    }
    class B extends A {
      constructor (b) {
        super( b)
        this.propB = b;
      }
    }
  3. O

    class A {
      constructor (a) {
        this.propA = a;
      }
    }
    class B extends A {
      constructor (a,b) {
        super( a)
        this.propB = b;
      }
    }
  4. O

    class A extends B {
      constructor (a) {
        this.propA = a;
      }
    }
    class B {
      constructor (a,b) {
        super( a)
        this.propB = b;
      }
    }

4.2. Question 2: Merging Subclasses

Consider the three classes A with a property propA, B with a property propB and C with a property propC, such that B and C are subclasses of A. Which of the following class definitions is the correct result of merging all three classes according to the Class Hierarchy Merge design pattern? Select one:

  1. O

    ACategoryEL = new Enumeration(["B","C"]);
    class Abc {
      constructor (a,b,c) {
        this.propA = a;
        if (b) this.propB = b;
        if (c) this.propC = c;
      }
    }
  2. O

    ACategoryEL = new Enumeration(["B","C"]);
    class Abc {
      constructor (a,cat,b,c) {
        this.propA = a;
        this.category = cat;  // from ACategoryEL
        if (b) this.propB = b;
        if (c) this.propC = c;
      }
    }
  3. O

    ACategoryEL = new Enumeration(["B","C"]);
    class Abc {
      constructor (a,cat,b,c) {
        this.propA = a;
        this.category = cat;  // from ACategoryEL
        this.propB = b;
        this.propC = c;
      }
    }
  4. O

    ACategoryEL = new Enumeration(["B","C"]);
    class Abc {
      constructor (a,cat) {
        this.propA = a;
        this.category = cat;  // from ACategoryEL
      }
    }

4.3. Question 3: Check Method for Segment Property

Recall that in a class resulting from applying the Class Hierarchy Merge design pattern, we have segment properties corresponding to the specific properties of the merged segment classes (subclasses).

How many parameters does the check method for a segment property have? Select one:

  1. O one

  2. O two

  3. O three