GkSeries.com

JavaScript Questions & Answers – Augmentation of Classes | JavaScript MCQs

(1) The four kinds of class members are ________
[A] Instance methods, Instance fields, Static method, Dynamic method
[B] Instance fields, Instance methods, Class fields, Class methods
[C] Instance fields, Non-instance fields, Dynamic methods, Global methods
[D] Global methods, Local methods, Dynamic methods, Static methods
Answer: Instance fields, Instance methods, Class fields, Class methods
(2) Different kinds of the object involved in a class definition are ________
[A] Public object, Private object, Protected object
[B] Constructor object, Function object, Destructor object
[C] Constructor object, Prototype object, Instance object
[D] Instance method, Static object, Dynamic object
Answer: Constructor object, Prototype object, Instance object

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

(3) The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is ________
[A] Instance object
[B] Constructor object
[C] Destructor object
[D] Prototype object
Answer: Prototype object
(4) Which variables are used internally in object methods and are also globally visible?
[A] Object properties
[B] Variable properties
[C] Method properties
[D] Internal properties
Answer: Variable properties
(5) The class that represents the regular expressions is ________
[A] RegExpObj
[B] RegExpClass
[C] RegExp
[D] StringExp
Answer: RegExp
(6) The different variant of Date() constructor to create date object is/are ___________

i. new Date(date)

ii. new Date(milliseconds)

iii. new Date(date string)

iv. new Date(year, month, date[hour, minute, second, millisecond])

[A] i, ii and iii only
[B] ii, iii and iv only
[C] i, ii and iv only
[D] i, ii, iii and iv
Answer: ii, iii and iv only
(7) 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); };
Answer: Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };
(8) How can we make methods available on all objects?
[A] Object.add(methods)
[B] Object.methods(add)
[C] Object.add.methods(…)
[D] Object.prototype
Answer: Object.prototype
(9) What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document?
[A] HTMLElement.prototype(…)
[B] HTMLElement.prototype
[C] HTML.addmethods()
[D] HTML.elements(add)
Answer: HTMLElement.prototype
(10) You can refresh the webpage in JavaScript by using ________
[A] window.reload
[B] location.reload
[C] window.refresh
[D] page.refresh
Answer: location.reload
(11) What will be the output of the following JavaScript code?
emp={id:102,name:"Shyam Kumar",salary:40000}  
   document.write(emp.id+" "+emp.name+" "+emp.salary);
[A] 102 4000 Shyam Kumar
[B] 102 4000
[C] 102 Shyam Kumar 40000
[D] 102 shyam kumar 40000
Answer: 102 4000
(12) What will be the output of the following JavaScript code?
function emp(id,name)
{  
    this.id=id;  
    this.name=name;    
}  
e=new emp(103,"Vimal Jaiswal");  
 
document.write(e.id+" "+e.name");
[A] 103 vimal jaiswal
[B] 103
[C] 103 Vimal Jaiswal
[D] Vimal jaiswal
Answer: 103 Vimal Jaiswal
(13) What will be the output of the following JavaScript code?
var emp=new Object();  
emp.name="Ravi Malik";  
emp.salary=50000;  
document.write("emp.name+" "+emp.salary);
[A] Ravi malik 5000
[B] Ravi Malik 50000
[C] Ravi malik
[D] 50000
Answer: Ravi Malik 50000
(14) What will be the output of the following JavaScript code?
function emp(name,salary)
{  
     this.name=name;  
     this.salary=salary;  
 
     this.changeSalary=changeSalary;  
     function changeSalary(otherSalary)
     {  
         this.salary=otherSalary;  
     }  
}  
e=new emp("Rahul",30000);  
e.changeSalary(45000);  
document.write("e.name+" "+e.salary);
[A] Rahul 30000
[B] Rahul
[C] Rahul 45000
[D] 45000
Answer: Rahul 45000
(15) What will be the output of the following JavaScript code?
const obj = { 10: 'arry', 21: 'barry', 23: 'carry' };  
console.log(Object.entries(obj)[2]);
[A] [“arry”, “10”]
[B] [“10”,”arry”]
[C] [“21”,barry”]
[D] [“23”,”carry”]
Answer: [“23”,”carry”]

Please share this page

Click Here to Read more questions

Teacher Eligibility Test