1.

Which is the correct code that returns a complex number that is the complex conjugate of this one?(a) Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };(b) Complex.prototype.conj = function() { return Complex(this.r, -this.i); };(c) Complex.prototype.conj = function() { return (this.r, -this.i); };(d) Complex.prototype.conj = function() { new Complex(this.r, -this.i); };I got this question in exam.My doubt stems from Augmentation of Classes topic in division Classes and Modules in JavaScript of JavaScript

Answer»

The correct answer is (a) Complex.prototype.conj = FUNCTION() { RETURN new Complex(this.r, -this.i); };

Explanation: OBJECT.prototype.constructor specifies the function that CREATES the object prototype. The above code snippet returns a complex number that is the complex CONJUGATE of this one.



Discussion

No Comment Found

Related InterviewSolutions