Home

JavaScript MCQ Solved Paper for NEET

Thursday 9th of March 2023

Sharing is caring

1. What will be the output of the following JavaScript code?
var grade='A';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10
B. 27
C. 8
D. 0
Answer : B
2. What will be the output of the following Javascript code?
var arr = [7, 5, 9, 1];
var min = Math.min.apply(null, arr);
document.writeln(min);

A. 7
B. 5
C. 1
D. 9
Answer : C
3. What will the following code snippet work? If not, what will be the error?
function tail(o)
{
for (; o.next; o = o.next) ;
return o;
}

A. No, this will throw an exception as only numerics can be used in a for loop
B. No, this will not iterate
C. Yes, this will work
D. No, this will result in a runtime error with the message Cannot use Linked List
Answer : C
4. What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?
A. The property will be stored in a cache
B. The loop will not run
C. That property will not be enumerated
D. The property will be enumerated
Answer : C
5. What will be the output of the following JavaScript code?
var values=[1,2,3,4]
var ans=values.slice(1);
document.writeln(ans);

A. 1, 2, 3, 4
B. 2, 3, 4
C. 1, 3, 4
D. error
Answer : D
6. When an empty statement is encountered, a JavaScript interpreter __________
A. Ignores the statement
B. Prompts to complete the statement
C. Throws an error
D. Shows a warning
Answer : A
7. What will be the output of the following JavaScript code?
var pow=new Function(num1,num2,return Math.pow(num1,num2));
document.writeln(pow(2,3));

A. 2
B. 3
C. 8
D. error
Answer : C
8. What will be the output of the following JavaScript code?
var string1 = 123;
var intvalue = 123;
alert( string1 + intvalue );

A. 123246
B. 246
C. 123123
D. Exception
Answer : C
9. What will be the step of the interpreter in a jump statement when an exception is thrown?
A. The interpreter stops its work
B. The interpreter throws another exception
C. The interpreter jumps to the nearest enclosing exception handler
D. The interpreter throws an error
Answer : C
10. The enumeration order becomes implementation dependent and non-interoperable if ___________
A. If the object inherits enumerable properties
B. The object does not have the properties present in the integer array indices
C. The delete keyword is never used
D. Object.defineProperty() is not used
Answer : A
11. What will be the output of the following JavaScript code?
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);

A. 20
B. 12
C. undefined
D. error
Answer : B
12. What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10
B. 0
C. 18
D. 17
Answer : B
13. A function with no return value is called ___________
A. Procedures
B. Method
C. Static function
D. Dynamic function
Answer : A
14. Which of the operator is used to test if a particular property exists or not?
A. in
B. exist
C. within
D. exists
Answer : A
15. In the following switch syntax, the expression is compared with the case labels using which of the following operator(s)?
switch(expression)
{
statements
}

A. ==
B. equals
C. equal
D. ===
Answer : D
16. What happens in the following javaScript code snippet?
var count = 0;
while (count < 10)
{
console.log(count);
count++;
}

A. The values of count are logged or stored in a particular location or storage
B. The value of count from 0 to 9 is displayed in the console
C. An error is displayed
D. An exception is thrown
Answer : B
17. Identify the process done in the following JavaScript code snippet?
o = {x:1, y:{z:[false,null,]}};
s = JSON.stringify(o);
p = JSON.parse(s);

A. Object Encapsulation
B. Object Serialization
C. Object Abstraction
D. Object Encoding
Answer : B
18. What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?
A. The property will be stored in a cache
B. The loop will not run
C. That property will not be enumerated
D. The property will be enumerated
Answer : C
19. What will be the output of the following JavaScript code?
function output(option)
{
return (option ? yes : no);
}
bool ans=true;
console.log(output(ans));

A. Yes
B. No
C. Runtime error
D. Compilation error
Answer : A
20. What will be the output of the following JavaScript code?
int a==2;
int b=4;
int ans=a+b;
print(ans);

A. 2
B. 6
C. 0
D. error
Answer : D
21. Consider the following code snippet.
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}

What will be the role of the continue keyword in the above code snippet?

A. The continue keyword restarts the loop
B. The continue keyword skips the next iteration
C. The continue keyword skips the rest of the statements in that iteration
D. The continue keyword breaks out of the loop
Answer : C
22. JavaScript can be written __________
A. directly into JS file and included into HTML
B. directly on the server page
C. directly into HTML pages
D. directly into the css file
Answer : A
23. The script tag must be placed in __________
A. the head tag
B. the head or body
C. the title or head
D. after the body tag
Answer : B
24. The main purpose of a Live Wire in NetScape is to ________
A. Create linkage between client side and server side
B. Permit server side, JavaScript code, to connect to RDBMS
C. Support only non relational database
D. To interpret JavaScript code
Answer : B
25. What will be the shift() output of the following JavaScript code?
var a = [];
a.unshift(1);
a.unshift(22);
a.shift();
a.unshift(3,[4,5]);
a.shift();
a.shift();
a.shift();

A. 1
B. [4,5]
C. [3,4,5]
D. Exception is thrown
Answer : A
26. JavaScript is a _______________ language.
A. Object-Oriented
B. High-level
C. Assembly-language
D. Object-Based
Answer : D
27. What will be the output of the following Javascript code?
function range(int length)
{
int a=5;
for(int i=0;i<length;i++)
{
console.log(a);
}
}
range(3);

A. 5
B. 555
C. 3
D. error
Answer : B
28. The method or operator used to identify the array is __________
A. isarrayType()
B. ==
C. ===
D. typeof
Answer : D
29. Consider the following code snippet.
for(var p in o)
console.log(o[p]);

The above code is equivalent to which code?

A.
for (var i = 0;i < a.length;i++)
console.log(a[i]);

B.
for (int i = 0;i < a.length;i++)
console.log(a[i]);

C.
for (var i = 0;i <= a.length;i++)
console.log(a[i]);

D.
for (var i = 1;i < a.length;i++)
console.log(a[i]);

Answer : A
30. What will be the equivalent output of the following JavaScript code snippet?
x = ~-y;
w = x = y = z;
q = a?b:c?d:e?f:g;

A.
x = ~(-y); w = (x = (y = z));
q = a?b:(c?d:(e?f:g));

B.
x = a?b:(c?d:(e?f:g));
q = ~(-y); w = (x = (y = z));

C.
x = (x = (y = z));w = ~(-y);
q = a?b:(c?d:(e?f:g));

D.
x = ~(-y); w = (x = (y = z));
q = (c?d:(e?f:g));

Answer : A
31. What will be the output of the following JavaScript code?
function info()
{
int a=1;
int b=2;
return a*b;
}
document.write(info());

A. 1
B. 2
C. 3
D. error
Answer : B
32. What will be the output of the following JavaScript code?
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.proerty1 = '20';
console.log(obj2.property1);

A. 10
B. 20
C. Runtime error
D. Compilation error
Answer : A
33. Consider the following code snippet.
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}

What will be the role of the continue keyword in the above code snippet?

A. The continue keyword restarts the loop
B. The continue keyword skips the next iteration
C. The continue keyword skips the rest of the statements in that iteration
D. The continue keyword breaks out of the loop
Answer : C
34. The unordered collection of properties, each of which has a name and a value is called _________
A. String
B. Object
C. Serialized Object
D. Array
Answer : B
35. What will be the output of the following JavaScript code?

A. 125
B. 25
C. 5
D. Error
Answer : C
36. The purpose of extensible attribute is to __________
A. make all of the own properties of that object non configurable
B. to configure and bring a writable property
C. lock down objects into a known state and prevent outside tampering
D. to include new properties into the object
Answer : C
37. What will be the output of the following Javascript code?
int size=5;
int a=5;
int size=4;
for(int j=size;j>=0;j--)
{
console.log(a);
a=a-2;
}

A. 5555
B. 5321
C. 531-1
D. 531
Answer : C
38. The enumeration order becomes implementation dependent and non-interoperable if ___________
A. If the object inherits enumerable properties
B. The object does not have the properties present in the integer array indices
C. The delete keyword is never used
D. Object.defineProperty() is not used
Answer : A
39. The pop() method of the array does which of the following task?
A. decrements the total length by 1
B. increments the total length by 1
C. prints the first element but no effect on the length
D. updates the element
Answer : A
40. What will be the output of the following JavaScript code?
int a=4;
int b=1;
int c=0;
If(a==b)
document.write(a);
else if(a==c)
document.write(a);
else
document.write(c);

A. 4
B. 1
C. Error
D. 0
Answer : D
41. Do functions in JavaScript necessarily return a value?
A. It is mandatory
B. Not necessary
C. Few functions return values by default
D. some functions do not return any value
Answer : C
42. What is a block statement in JavaScript?
A. conditional block
B. block that contains a single statement
C. both conditional block and a single statement
D. block that combines multiple statements into a single compound statement
Answer : D
43. What will be the output of the following JavaScript code?
function compare()
{
int a=1;
char b=1;
if(a.tostring()===b)
return true;
else
return false;
}

A. true
B. false
C. runtime error
D. logical error
Answer : A
44. Which is a more efficient JavaScript code snippet?
Code 1 :
for(var num=10;num>=1;num--)
{
document.writeln(num);
}

Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}

A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare
Answer : A
45. What will be the output of the following JavaScript code?
function code(id,name)
{
this.id = id;
this.name = name;
}
function pcode(id,name)
{
code.call(this,id,name);
}
document.writeln(new pcode(101,vivek).id);

A. vivek
B. 101
C. Runtime error
D. Compilation error
Answer : B
46. Among the keywords below, which one is not a statement?
A. debugger
B. with
C. if
D. use strict
Answer : D
47. A JavaScript program developed on a Unix Machine ________
A. will throw errors and exceptions
B. must be restricted to a Unix Machine only
C. will work perfectly well on a Windows Machine
D. will be displayed as a JavaScript text on the browser
Answer : C
48. Which of the following Attribute is used to include External JS code inside your HTML Document?
A. src
B. ext
C. script
D. link
Answer : A
49. What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2

A. true false
B. false true
C. true tue
D. false true
Answer : A
50. What will be the output of the following JavaScript code?
const object1 = {
property1: 20
};
console.log(Object.is(object1));

A. 20
B. true
C. false
D. error
Answer : C

Sharing is caring