0% found this document useful (0 votes)
78 views

Java Script MCQ Set Paper 2

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Java Script MCQ Set Paper 2

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

[Type]0

[Marks]1
[Negative Marks]0

Q.1) What is JavaScript?

[a] JavaScript is a compiled language used to make the website interactive


[b] JavaScript is an assembly language used to make the website interactive
*[c] JavaScript is a scripting language used to make the website interactive
[d] None of the mentioned

[S1] This is for the solution

Q.2) Which of the following is correct about JavaScript?

[a] JavaScript is Assembly-language


*[b] JavaScript is an Object-Based language
[c] JavaScript is an Object-Oriented language
[d] JavaScript is a High-level language

[S1] This is for the solution

Q.3) What will be the output of the following code snippet?


<xmp><script type="text/javascript" language="javascript"></xmp>

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

[S1] This is for the solution

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

[S1] This is for the solution


Q.5) Arrays in JavaScript are defined by which of the following statements?

[a] It is an ordered list of objects


*[b] It is an ordered list of values
[c] It is an ordered list of string
[d] It is an ordered list of functions

[S1] This is for the solution

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

[S1] This is for the solution

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

[S1] This is for the solution


Q.8) Which one of the following is the correct way for calling the
JavaScript code?
*[a] Function/Method
[b] RMI
[c] Triggering Event
[d] Preprocessor

[S1] This is for the solution

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

Q.10) In a javascript what function can be used to send messages to users


requesting for an text input?
[a]Display()
[b]Alert()
*[c]Prompt()
[d]Getoutput()

[S1] This is for the solution

Q.11) What is the correct javascript syntax to write(“hello world”)?


[a]system.out.println(“hello world”)
*[b]document.write(“hello world”)
[c]println(“hello world”)
[d]none of the above

[S1] This is for the solution

Q.12) How does javascript store dates in a data object?


*[a]the number of milliseconds since January 1st 1970
[b]the number of days since January 1st 1900
[c]the number of seconds since netscape’s public stock offer
[d]none of the above

[S1] This is for the solution

Q.13) What is the output for the following?


<xmp><script></xmp>
Function x()
{
document.write(2+5+”8”);
}
<xmp></script></xmp>

[a]258
[b]error
[c]7
*[d]78

[S1] This is for the solution

Q.14) How to create date object in javascript?


[a] dateobjectName.new Date([parameters])
*[b]dateobjectName = new Date([parameters])
[c] dateobjectName:= new Date([parameters])
[d]none of the above

[S1] This is for the solution

Q.15) Which of the following operator is used to concatenate two strings?


[a]Dot
[b]Comma
*[c]Plus
[d]Arrow

[S1] This is for the solution

Q.16) What will be the output of the following code snippet?


a = [1, 2, 3, 4, 5, 6];
document.write(a.slice(2, 3));

[a]2,3
*[b]3,4,5,6
[c]3,4,5
[d]2,3,4

[S1] This is for the solution

Q.17) What happens when we run this code?


function dog() {
document.write("I am a dog.");
}
dog.sound = "Bark";

*[a]nothing happens
[b]syntax error
[c]reference error
[d]”I am a dog” is printed

[S1] This is for the solution


Q.18) What will be the output of the following code snippet?
const obj1 = {first: 20, second: 30, first: 50};
console.log(obj1);

[a] {first: 20, second: 30}


*[b] {first: 50, second: 30}
[c] {first: 20, second: 30,first:50}
[d] syntax error

[S1] This is for the solution

Q.19) What is mean by “This” keyword in javascript?

*[a] It refers current object


[b] It refers previous object
[c]It is variable which contain values
[d]none of the above

[S1] This is for the solution

Q.20) Javascript provides us following types of dialog boxes?


[a] alert
[b] prompt
[c] modal
*[d] both A and B

[S1] This is for the solution

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

[S1] This is for the solution

Q.22) The pop () method of the array does which of the following task?

[a] increments the total length by 1


*[b] removes the element which is present in last index of an array
[c] prints the first element but no effect on the length
[d] None of the mentioned
[S1] This is for the solution

Q.23) What is the purpose of a return statement in a function?

[a] Returns the value and executing the function


[b] Returns the value and stops the program
*[c] Stops executing the function and returns the value
[d]none of the above

[S1] This is for the solution

Q.24) How do you create a function in javascript?

[a] function:myFunction()
[b]function=myFunction()
*[c]function myFunction()
[d] function=myFunction

[S1] This is for the solution

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

[S1] This is for the solution

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()

[S1] This is for the solution

Q.27) How do you declare a javascript variable?

[a]variable carName;
[b]v carName;
*[c]var carName;
[d] Both A and B

[S1] This is for the solution

Q.28) 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] Error
*[b] 1, 2, 3, 6, 7, 8
[c]123
[d] 1, 2, 3

[S1] This is for the solution

Q.29) Is it possible to nest function in javascript?

*[a]true
[b]false

[S1] This is for the solution

Q.30) What will be the output of the following code snippet?


const obj1 = {Name: "Hello", Age: 16};
const obj2 = {Name: "Hello", Age: 16};
document.write(obj1 === obj2);

[a]true
*[b]false
[c]undefined
[d]none of the above

[S1] This is for the solution

You might also like