JavaScript Questions & Answers – Classes in JavaScript | JavaScript MCQs
Questions
1
The behaviour of the instances present of a class inside a method is defined by __________
Answer: Classes
2
The keyword or the property that you use to refer to an object through which they were invoked is _________
Answer: this
⭐ Make GKSeries Your Preferred Source on Google
Add GKSeries as Preferred Source
3
What will be the output of the following JavaScript code?
var o = new F();o.constructor === F
Answer: true
4
The basic difference between JavaScript and Java is _________
Answer: Functions are values, and there is no hard distinction between methods and fields
5
The meaning for Augmenting classes is that ___________
Answer: objects inherit prototype properties even in a dynamic state
6
The property of JSON() method is __________
Answer: it is invoked automatically by the JSON.stringify() method
7
When a class B can extend another class A, we say that?
Answer: A is the superclass and B is the subclass
8
If A is the superclass and B is the subclass, then subclass inheriting the superclass can be represented as _________
Answer: B.prototype=inherit(A);
9
The snippet that filters the filtered set is __________
Answer: var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});
10
The method that can be used to create new properties and also to modify the attributes of existing properties is _________
Answer: Both Object.defineProperty() and Object.defineProperties()
11
What will be the output of the following JavaScript code?
const obj1 =
{
a: 10,
b: 15,
c: 18
};
const obj2 = Object.assign({c: 7, d: 1}, obj1);
console.log(obj2.c, obj2.d);
Answer: 7,1
12
What will be the output of the following JavaScript code?
function person()
{
this.name = 'rahul';
}
function obj()
{
obj.call(this)
}
obj.prototype = Object.create(person.prototype);
const app = new obj();
console.log(app.name);
Answer: rahul
13
What will be the output of the following JavaScript code?
const object1 = {};
Object.defineProperties(object1,
{
property1:
{
value: 10
}
});
console.log(object1.property1);
Answer: 10
14
What will be the output of the following JavaScript code?
const prototype1 = {};
const object1 = Object.create(prototype1);
console.log(Object.getPrototypeOf(object1) === prototype1);
Answer: true
15
What will be the output of the following JavaScript code?
const obj1 = {
property1: 2
};
Object.seal(object1);
obj1.property1 =4;
console.log(obj1.property1);
delete obj1.property1;
Answer: Error