4. Quiz Questions

If you would like to look up the answers for the following quiz questions, you can check our discussion forum. If you don't find an answer in the forum, you may create a post asking for an answer to a particular question.

If you would like to do interactive quizzes with online feedback and with the option to ask a coach, then you should enrol in the advanced online course (book parts 4-5) offered by our partner developer-competence.com.

4.1. Question 1: Constructor-Based Inheritance Pattern

Which code fragment is correctly defining the constructor-based inheritance pattern where the subclass B inherits from the superclass A?

Select one:

  1. O

    function A(a) { 
      this.a = a; 
    } 
    function B(a,b) {
      A(a);
      this.b = b;
    }
    B.prototype = Object.create( A.prototype);
    B.prototype.constructor = B;
  2. O

    function A(a) {
      this.a = a;
    }
    function B(a,b) {
      A.call( this, a); 
      this.b = b; 
    }
    A.prototype = Object.create( B.prototype);
    B.prototype.constructor = B;
  3. O

    function A(a) { 
      this.a = a; 
    } 
    function B(a,b) { 
      this.a = a; 
      this.b = b; 
    }
    B.prototype = Object.create( A.prototype);
    B.prototype.constructor = B;
  4. O

    function A(a) {
      this.a = a;
    }
    function B(a,b) {
      A.call( this, a); 
      this.b = b; 
    }
    B.prototype = Object.create( A.prototype);
    B.prototype.constructor = B;

4.2. Question 2: 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 properties of the merged segment classes (subclasses).

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

Answer: ________