Home

JavaScript MCQ Solved Paper for CTET

Thursday 9th of March 2023

Sharing is caring

1. Among the following, which one is a ternary operator?
A. +
B. :
C. ^
D. ?:
Answer : D
2. What will be the output of the following JavaScript code?
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);

A. one
B. two
C. three
D. error
Answer : A
3. What will be the output of the following Javascript code?
var a= 0;
var b = 0;
while (a < 3)
{
a++;
b += a;
console.log(b);
}

A. 135
B. 123
C. 013
D. 01
Answer : A
4. The object has three object attributes namely ________
A. Class, parameters, objects extensible flag
B. Prototype, class, objects parameters
C. Prototype, class, objects extensible flag
D. Native object, Classes and Interfaces and Objects extensible flag
Answer : C
5. What will be the output of the following JavaScript code?
var arr=[1,2,3];
var rev=arr.reverse();
document.writeln(rev);

A. 1, 2, 3
B. 3, 2, 1
C. 3
D. 1
Answer : B
6. What will happen if reverse() and join() methods are used simultaneously?
A. Reverses and stores in the same array
B. Reverses and concatenates the elements of the array
C. Reverses
D. Stores the elements of an array in normal order
Answer : A
7. 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
8. What will be the output of the following Javascript code?
var a=3.7;
var b=2;
a=ciel(a)
document.writeIn(a*b);

A. 6
B. 7.4
C. 7.5
D. 8
Answer : D
9. The function definitions in JavaScript begins with _____________
A. Identifier and Parentheses
B. Return type and Identifier
C. Return type, Function keyword, Identifier and Parentheses
D. Identifier and Return type
Answer : C
10. For the below mentioned code snippet:
var o = new Object();

The equivalent statement is:

A. var o = Object();
B. var o;
C. var o= new Object;
D. Object o=new Object();
Answer : C
11. 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
12. What will be the output of the following JavaScript code?
var val1=[1,2,3];
var val2=[6,7,8];
var result=val1.concat(val2);
document.writeln(result);

A. 1, 2, 3
B. Error
C. 1, 2, 3, 6, 7, 8
D. 123
Answer : C
13. What will be the output of the following JavaScript code?
int a=1;
if(a!=null)
return 1;
else
return 0;

A. 1
B. 0
C. runtime error
D. compiler error
Answer : A
14. 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
15. 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
16. Among the keywords below, which one is not a statement?
A. debugger
B. with
C. if
D. use strict
Answer : D
17. 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
18. What will be the output of the following JavaScript code?
function compare()
{
int num=2;
char b=2;
if(a==b)
return true;
else
return false;
}

A. true
B. false
C. runtime error
D. compilation error
Answer : A
19. To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the ____________
A. isPrototypeOf() method
B. equals() method
C. === operator
D. ==opertor
Answer : A
20. 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
21. When does the function name become optional in JavaScript?
A. When the function is defined as a looping statement
B. When the function is defined as expressions
C. When the function is predefined
D. when the function is called
Answer : B
22. What will be the equivalent code of the following JavaScript code?
o.m(x,y);

A. o.m(x) && o.m(y);
B. o[m](x,y);
C. o(m)[x,y];
D. o.m(x && y);
Answer : B
23. The one-liner code that concatenates all strings passed into a function is
A.
function concatenate()
{
return String.prototype.concat('', arguments);
}

B.
function concatenate()
{
return String.prototype.apply('', arguments);
}

C.
function concatenate()
{
return String.concat.apply('', arguments);
}

D.
function concatenate()
{
return String.prototype.concat.apply('', arguments);
}

Answer : D
24. 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
25. 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
26. What will be the output of the following Javascript code?
<script>
var x = 5;
var y = 2;
var z = x % y;
document.getElementById("demo").innerHTML = z;
</script>



A. 0
B. 1
C. 2
D. 5
Answer : B
27. What kind of expression is new Point(2,3)?
A. Primary Expression
B. Object Creation Expression
C. Invocation Expression
D. Constructor Calling Expression
Answer : B
28. 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
29. 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
30. The method or operator used to identify the array is __________
A. isarrayType()
B. ==
C. ===
D. typeof
Answer : D
31. 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
32. What will be the output of the following JavaScript code?
var a=5 , b=1
var obj = { a : 10 }
with(obj)
{
alert(b)
}

A. 10
B. Error
C. 1
D. 5
Answer : C
33. 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
34. Which attribute is used to specify that the script is executed when the page has finished parsing? (only for external scripts)
A. parse
B. a sync
C. defer
D. type
Answer : C
35. 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
36. JavaScript is a _______________ language.
A. Object-Oriented
B. High-level
C. Assembly-language
D. Object-Based
Answer : D
37. 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
38. What will be the output of the following JavaScript code?

A. 125
B. 25
C. 5
D. Error
Answer : C
39. What are the three important manipulations done in a for loop on a loop variable?
A. Updation, Incrementation, Initialization
B. Initialization,Testing, Updation
C. Testing, Updation, Testing
D. Initialization,Testing, Incrementation
Answer : B
40. What will happen if a return statement does not have an associated expression?
A. It returns the value 0
B. It will throw an exception
C. It returns the undefined value
D. It will throw an error
Answer : C
41. A function definition expression can be called as __________
A. Function prototype
B. Function literal
C. Function calling
D. Function declaration
Answer : B
42. 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
43. 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
44. What will be the output of the following JavaScript code?
function printprops(o)
{
for(var p in o)
console.log(p + : + o[p] +
);
}

A. Prints the contents of each property of o
B. Returns undefined
C. Prints only one property
D. Prints the address of elements
Answer : B
45. What will be the output of the following JavaScript code?
function output(object)
{
var place=object ? object.place : Italy;
return clean:+ place;
}
console.log(output({place:India}));

A. clean:India
B. clean:Italy
C. error
D. undefined
Answer : A
46. 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
47. JavaScript Code can be called by using ___________
A. RMI
B. Triggering Event
C. Preprocessor
D. Function/Method
Answer : D
48. A conditional expression is also called a _______________
A. Alternative to if-else
B. Immediate if
C. If-then-else statement
D. Switch statement
Answer : B
49. Consider the following code snippet :
var string2Num=parseInt(123xyz);

The result for the above code snippet would be :

A. 123
B. 123xyz
C. Exception
D. NaN
Answer : A
50. What are the three important manipulations done in a for loop on a loop variable?
A. Updation, Incrementation, Initialization
B. Initialization,Testing, Updation
C. Testing, Updation, Testing
D. Initialization,Testing, Incrementation
Answer : B

Sharing is caring