Java Script MCQ Set Paper 2
Java Script MCQ Set Paper 2
[Marks]1
[Negative Marks]0
var x=12;
var y=8;
var res=eval("x+y");
document.write(res);
<xmp></script></xmp>
[a]128
[b]x+y
*[c]20
[d]none of the above
Q.4) What will be the output for the following code snippet?
<xmp> <p id="example"></p></xmp>
<xmp> <script> </xmp>
function Func()
{
document.getElementById("example").innerHTML=Math.sqrt(81);
}
<xmp></script></xmp>
*[a]9
[b]0
[c]81
[d]error
Q.6) Which of the following is the correct output for the following
JavaScript code?
var x=3;
var y=2;
var z=0;
if(x==y)
document.write(x);
elseif(x==z)
document.write(x);
else
document.write(z);
[a]3
[b]error
*[c]0
[d]2
Q.7) Which of the following is the correct output for the following
JavaScript code?
var grade='C';
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]8
[c]17
[d]error
Q.9) Identify the correct code in order to fetch the value entered in
username text field
<xmp>< body></xmp>
<xmp>< form></xmp>
Enter username </xmp> < input value="John" id="name" name="username"></xmp>
<xmp>< /form></xmp>
<xmp>< /body></xmp>
[a] document.register.name.value
[b] document.getElementByName ("name").value
*[c] document.getElementById ("name").value
[d]none of the above
[a]258
[b]error
[c]7
*[d]78
[a]2,3
*[b]3,4,5,6
[c]3,4,5
[d]2,3,4
*[a]nothing happens
[b]syntax error
[c]reference error
[d]”I am a dog” is printed
Q.21) Which one of the following is correct output for the following given
JavaScript code?
string X= "Good";
string Y="Evening";
alert(X+Y);
[a]Good
[b]Evening
*[c]GoodEvening
[d]undefined
Q.22) The pop () method of the array does which of the following task?
[a] function:myFunction()
[b]function=myFunction()
*[c]function myFunction()
[d] function=myFunction
Q.25) How many ways are there in javascript to insert a code in HTML?
[a]1
*[b]3
[c]4
[d]none of the above
Q.26) How do you round the number 7.25 to the nearest integer?
[a]rnd(7.25)
*[b]math.round(7.25)
[c]round(7.25)
[d]round()
[a]variable carName;
[b]v carName;
*[c]var carName;
[d] Both A and B
[a] Error
*[b] 1, 2, 3, 6, 7, 8
[c]123
[d] 1, 2, 3
*[a]true
[b]false
[a]true
*[b]false
[c]undefined
[d]none of the above