JavaScript Questions & Answers – Augmentation of Classes | JavaScript MCQs
Questions
1
The four kinds of class members are ________
Answer: Instance fields, Instance methods, Class fields, Class methods
2
Different kinds of the object involved in a class definition are ________
Answer: Constructor object, Prototype object, Instance object
⭐ Make GKSeries Your Preferred Source on Google
Add GKSeries as Preferred Source
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 ________
Answer: Prototype object
4
Which variables are used internally in object methods and are also globally visible?
Answer: Variable properties
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])
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?
Answer: Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };
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?
Answer: HTMLElement.prototype
10
You can refresh the webpage in JavaScript by using ________
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);
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");
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);
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);
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]);
Answer: [“23”,”carry”]