JavaScript Questions & Answers – Classes in JavaScript | JavaScript MCQs

Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Questions
1 The behaviour of the instances present of a class inside a method is defined by __________
A Method
B Classes
C Interfaces
D Classes and Interfaces

Answer: Classes
2 The keyword or the property that you use to refer to an object through which they were invoked is _________
A from
B to
C this
D object

Answer: this
Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
3 What will be the output of the following JavaScript code?
var o = new F();
o.constructor === F
A false
B true
C 0
D 1

Answer: true
4 The basic difference between JavaScript and Java is _________
A There is no difference
B Functions are considered as fields
C Variables are specific
D Functions are values, and there is no hard distinction between methods and fields

Answer: Functions are values, and there is no hard distinction between methods and fields
5 The meaning for Augmenting classes is that ___________
A objects inherit prototype properties even in a dynamic state
B objects inherit prototype properties only in a dynamic state
C objects inherit prototype properties in the static state
D object doesn’t inherit prototype properties in the static state

Answer: objects inherit prototype properties even in a dynamic state
6 The property of JSON() method is __________
A it can be invoked manually as object.JSON()
B it will be automatically invoked by the compiler
C it is invoked automatically by the JSON.stringify() method
D it cannot be invoked in any form

Answer: it is invoked automatically by the JSON.stringify() method
7 When a class B can extend another class A, we say that?
A A is the superclass and B is the subclass
B B is the superclass and A is the subclass
C Both A and B are the superclass
D Both A and B are the subclass

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 _________
A B=inherit(A);
B B=A.inherit();
C B.prototype=inherit(A);
D B.prototype=inherit(A.prototype);

Answer: B.prototype=inherit(A);
9 The snippet that filters the filtered set is __________
A var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});
B var t=new FilteredSet{function(s) {return !(x instanceof Set);});
C var t=new FilteredSet(s, {function(s) {return (x instanceof Set);});
D var t=new FilteredSet(s, {function(s) {return x;});

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 _________
A Object.defineProperty()
B Object.defineProperties()
C Both Object.defineProperty() and Object.defineProperties()
D Object.inherit()

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);
A 7,1
B 18,1
C Undefined
D Error

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);
A undefined
B runtime error
C compilation error
D rahul

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);
A 0
B 10
C undefined
D error

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);
A true
B false
C error
D 0

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;
A 2
B 4
C Error
D Undefined

Answer: Error

Random GK Questions

Assam Direct Recruitment Test Series

Teacher Eligibility Test

Assam Direct Recruitment Test Series