Wednesday, May 6, 2009

JAVASCRIPT - Objective type Questions

Previous Next


What is the correct JavaScript syntax to write "Hello World"?

1. response.write("Hello World")

2. document.write("Hello World")

3. ("Hello World")

4. "Hello World"


An external JavaScript must contain the <> tag

a) False

b) True


How do you write "Hello World" in an alert box?


a) alert("Hello World")

b) alertBox="Hello World"

c) alertBox("Hello World")

d) msgBox("Hello World")


How do you create a function?

a) function myFunction()

b) function=myFunction()

c) function:myFunction()


How do you call a function named "myFunction"?

a) call function myFunction

b) myFunction()

c) call myFunction()


How do you write a conditional statement for executing some statements only if "i" is equal to 5?

if (i==5)

if i=5

if i=5 then

if i==5 then


How many different kind of loops are there in JavaScript?

Two. The "for" loop and the "while" loop

Four. The "for" loop, the "while" loop, the "do...while" loop, and the "loop...until" loop

One. The "for" loop


How does a "for" loop start?

for (i = 0; i < = 5) for i = 1 to 5 for (i = 0; i < = 5; i++) for (i < = 5; i++) How can you add a comment in a JavaScript? //This is a comment < !--This is a comment-- >

'This is a comment


What is the correct JavaScript syntax to insert a comment that has more than one line?

//This comment has
more than one line//

/*This comment has
more than one line*/

< !--This comment has more than one line-- >
What is the correct way to write a JavaScript array?


var txt = new Array("tim","kim","jim")

var txt = new Array="tim","kim","jim"

var txt = new Array:1=("tim")2=("kim")3=("jim")

var txt = new Array(1:"tim",2:"kim",3:"jim")



How do you round the number 7.25, to the nearest whole number?

Math.round(7.25)

round(7.25)

rnd(7.25)

Math.rnd(7.25)



How do you find the largest number of 2 and 4?

Math.max(2,4)

ceil(2,4)

top(2,4)

Math.ceil(2,4)



What is the correct JavaScript syntax for opening a new window called "window2" ?

new("http://www.w3schools.com","window2")

new.window("http://www.w3schools.com","window2")

window.open("http://www.w3schools.com","window2")

open.new("http://www.w3schools.com","window2")



How do you put a message in the browser's status bar?

window.status("put your message here")

window.status = "put your message here"

status("put your message here")

statusbar = "put your message here"



How do you find the client's browser name?

client.navName

browser.name

navigator.appName


Previous Next

No comments:

Post a Comment