Java Script MCQ Set Paper 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

[Type]0

[Marks]1
[Negative Marks]0

Q.1) 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.2) How do you call a function named “myFunction”?


[a]call myFunction()
*[b]myFunction()
[c]callFunction myFunction()
[d]Function()

[S1] This is for the solution

Q.3) How to write an if statement in javascript?


[a]if i===5
[b]if i=5
[c]if i==5 then
*[d]if(i==5)

[S1] This is for the solution

Q.4) How does whileloop starts?


*[a]while(i<=10)
[b]while i=1 to 10
[c]while(i<=10;i++)
[d]while i=10

[S1] This is for the solution

Q.5) 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.6) 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.7) How do you write “hello world” in an alert box?
[a]alertbox(“hello world”)
*[b]alert(“hello world”)
[c]msg(“hello world”)
[d]print(“hello world”)

[S1] This is for the solution

Q.8) What is the correct way to write a javascript array?


*[a] var colors=[“red”,”green”,”blue”]
[b]var colors=[“red” ”green” ”blue”]
[c]color=[“red”,”green”,”blue”]
[d] Both [a] and [b] options are correct

[S1] This is for the solution

Q.9) What is built in method sorts the element of an array

[a]shift()
[b]push()
[c]order()
*[d]sort()

[S1] This is for the solution

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?

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

[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) ”+=” operator can operate on following data values.


[a]Integer
[b]Float
[c]String
*[d]All of the above

[S1] This is for the solution

Q.17) In the following given syntax of the switch statement, the Expression
is compared with the labels using which one of the following operators?

[a]==
[b]equals
*[c] ===
[d]none of the above

[S1] This is for the solution

Q.18) Which of the following function of the String object returns the
character in the string starting at the specified position via the specified
number of characters?
*[a] substr()
[b] split()
[c] slice()
[d] search()

[S1] This is for the solution

Q.19) Which property specifies the property of the event?


[a] Manner
[b] Target
*[c] Type
[d] Program

[S1] This is for the solution

Q.20) The object has three object attributes namely ________


[a] Class, parameters, object’s extensible flag
*[b] Prototype, class, object’s extensible flag
[c] Prototype, class, objects’ parameters
[d] Native object, Classes and Interfaces and Object’s extensible flag

[S1] This is for the solution

Q.21) 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.22) How to open new browser window?


[a]open(path)
*[b]window open(“file path”)
[c]open(“file path”)
[d]window open()

[S1] This is for the solution

Q.23) 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.24) Cookies were originally designed for __________

[a] Web programming


[b] Client-side programming
*[c] Server-side programming
[d] Both Client-side & Server-side programming

[S1] This is for the solution

Q.25) What is the constraint on the data per cookie?


[a] 2 KB
*[b] 4 KB
[c] 3 KB
[d] 1 KB

[S1] This is for the solution

Q.26) Which of the following defines the Cookie visibility?


[a] domain Path
*[b] local & session storage
[c] server storage
[d] transient Path

[S1] This is for the solution

Q.27) To which object does the location property belong?


[a]Position
[b]Element
*[c] Window
[d]Location

[S1] This is for the solution

Q.28) What is the most essential purpose of parentheses in regular


expressions?
[a] Define pattern matching techniques
[b] matching the complete string
*[c] Define subpatterns within the complete pattern
[d] Define portion of strings in the regular expression

[S1] This is for the solution

Q.29) The method that performs the search-and-replace operation to strings


for pattern matching is _______

[a] searchandreplace()
*[b] replace()
[c] edit()
[d] add()

[S1] This is for the solution


Q.30) The ‘$’ present in the RegExp object is called a ____________
[a] character
[b] metadata
[c] matcher
*[d] metacharacter

[S1] This is for the solution

You might also like