Classes And Modules(Computer Science > Javascript ) Questions and Answers

Question 1. The behaviour of the instances present of a class inside a method is defined by
  1.    Method
  2.    Classes
  3.    Interfaces
  4.    Classes and Interfaces
Explanation:-
Answer: Option B. -> Classes

Question 2. Consider the following code snippet :
var o = new F();
o.constructor === F
The output would be :
  1.    false
  2.    true
  3.    0
  4.    1
Explanation:-
Answer: Option B. -> true

Question 3. The keyword or the property that you use to refer to an object through which they were invoked is
  1.    from
  2.    to
  3.    this
  4.    object
Explanation:-
Answer: Option C. -> this

Question 4. The meaning for Augmenting classes is that
  1.    objects inherit prototype properties even in dynamic state
  2.    objects inherit prototype properties only in dynamic state
  3.    objects inherit prototype properties in static state
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> objects inherit prototype properties even in dynamic state

Question 5. The basic difference between JavaScript and Java is
  1.    There is no difference
  2.    Functions are considered as fields
  3.    Variables are specific
  4.    Functions are values, and there is no hard distinction between methods and fields
Explanation:-
Answer: Option D. -> Functions are values, and there is no hard distinction between methods and fields

Question 6. The property of JSON() method is:
  1.    it can be invoked manually as object.JSON()
  2.    it will be automatically invoked by the compiler
  3.    it is invoked automatically by the JSON.stringify() method
  4.    it cannot be invoked in any form
Explanation:-
Answer: Option C. -> it is invoked automatically by the JSON.stringify() method

Question 7. If A is the superclass and B is the subclass, then subclass inherting the superclass can be represented as
  1.    B=inherit(A);
  2.    B=A.inherit();
  3.    B.prototype=inherit(A);
  4.    B.prototype=inherit(A.prototype);
Explanation:-
Answer: Option C. -> B.prototype=inherit(A);

Question 8. The snippet that filters the filtered set is
  1.    var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});
  2.    var t=new FilteredSet{function(s) {return !(x instanceof Set);});
  3.    var t=new FilteredSet(s, {function(s) {return (x instanceof Set);});
  4.    var t=new FilteredSet(s, {function(s) {return x;});
Explanation:-
Answer: Option A. -> var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});

Question 9. When a class B can extend another class A, we say that
  1.    A is the superclass and B is the subclass
  2.    B is the superclass and A is the subclass
  3.    Both A and B are the superclass
  4.    Both A and B are the subclass
Explanation:-
Answer: Option A. -> A is the superclass and B is the subclass

Question 10. The method that can be used to create new properties and also to modify the attributes of existing properties is
  1.    Object.defineProperty()
  2.    Object.defineProperties()
  3.    Both Object.defineProperty() and Object.defineProperties()
  4.    None of the mentioned
Explanation:-
Answer: Option C. -> Both Object.defineProperty() and Object.defineProperties()