Friday, January 8, 2010

Javascript Quiz Questions and Answers



You can earn a 50% commission by promoting my ebooks, and if you are in India you can get my ebooks at a very low price from here.

Find below MCQ (Multiple Choice) questions and Answers useful for learning Javascript.
1) <script type="text/javascript">
x=4+"4";
document.write(x);
</script>

Output------?
a) 44
b) 8
c) 4
d) Error output
Show Answer

2) <script type="text/javascript" language="javascript">
var qpt = "Qualiyt Point Technologies";
var result = qpt.split(" ");
document.write(result);

</script>
a) Quality
b) Q,u,a,l,i,t,y,P,o,i,n,t,T,e,c,h,n,o,l,o,g,i,e,s
c) Qualiyt,Point,Technologies
d) QualityPointTechnologies
Show Answer

3) Is it possible to nest functions in JavaScript?
a) True
b) False
Show Answer

4) <script>
document.write(navigator.appCodeName);
</script>
a) get code name of the browser of a visitor
b) set code name of the browser of a visitor
c) None of the above
Show Answer

5) Which of the following is true?
a) If onKeyDown returns false, the key-press event is cancelled.
b) If onKeyPress returns false, the key-down event is cancelled.
c) If onKeyDown returns false, the key-up event is cancelled.
d) If onKeyPress returns false, the key-up event is canceled.
Show Answer

6) Scripting language are
a) High Level Programming language
b) Assembly Level programming language
c) Machine level programming language
Show Answer

7) Which best explains getSelection()?
a) Returns the VALUE of a selected OPTION.
b) Returns document.URL of the window in focus.
c) Returns the value of cursor-selected text
d) Returns the VALUE of a checked radio input.
Show Answer

8) <script language="javascript">
function x()
{
var s= "Good 100%";
var pattern = /\D/g;
var output= s.match(pattern);
document.write(output);
}
</script>
a) Good %
b) 1,0,0
c) G,o,o,d,%
d) Error
Show Answer

9) <script language="javascript">
var qpt="QUALITY POINT TECHNOLOGIES";
alert
(qpt.charAt(qpt.length-1));
</script>
a) P
b) E
c) S
d) Error
Show Answer

10) Choose the client-side JavaScript object:
a) Database
b) Cursor
c) Client
d) FileUpLoad
Show Answer

11) Are java and javascript the same?
a) NO
b) YES
Show Answer

12) Syntax for creating a RegExp object:
(a). var txt=new RegExp(pattern,attributes);
(b). var txt=/pattern/attributes;
Which of the above mentioned syntax will correct?
a) (a) only
b) (b) only
c) Both (a) and (b)
d) None of the above
Show Answer

13) <script language="javascript">
function x(z,t)
{
alert(x.length);
}
</script>
output:
?
a) Error
b) 2
c) 1
d) 3
Show Answer

14) What is mean by "this" keyword in javascript?
a) It refers current object
b) It referes previous object
c) It is variable which contains value
d) None of the above
Show Answer

15) In JavaScript, Window.prompt() method return true or false value ?
a) False
b) True
c) None of above
Show Answer

16) Math. round(-20.51)=?
a) 20
b) -21
c) 19
d) None
Show Answer

17) <script language="javascript">
function x()
{
var s = "Quality 100%!{[!!";
var pattern = /\w/g;
var output = s.match(pattern);
document.write(output);
}
</script>
a) %,!,{,[,!,!
b) Q,u,a,l,i,t,y,1,0,0
c) Quality 100
d) Error
Show Answer

18) <script type="text/javascript" language="javascript">
var qpt= new Array();
qpt[0] = "WebDevelopment";
qpt[1]="ApplicationDevelopment"
qpt[2]="Testing"
qpt[3] = "QualityPointTechnologies";
document.write(qpt[0,1,2,3]);
</script>
a) Error
b) QualityPointTechnologies
c) WebDevelopment
d) WebDevelopmnet,ApplicationDevelopment,Testing,QualityPointTechnologies
Show Answer

19) Choose the server-side JavaScript object:
a) FileUpLoad
b) Function
c) File
d) Date
Show Answer

20) parseFloat(9+10)=?
a) 19
b) 910
c) None
Show Answer

21) <script language="javascript">
function x()
{
document.write(2+5+"8");
}
</script>
a) 258
b) Error
c) 7
d) 78
Show Answer

22)_________ keyword is used to declare variables in javascript.
a) Var
b) Dim
c) String
Show Answer

23) In Javascript, Which of the following method is used to evaluate the regular expression?
a) eval(2*(3+5))
b) evaluate(2*(3+5))
c) evalu(2*(3+5))
d) None of the above
Show Answer

24) <script language="javascript">
function x()
{
var s= "quality 100%";
var pattern = /\d/g;
var output= s.match(pattern);
document.write(output);
}
</script>
a) 100
b) 1,0,0
c) q,u,a,l,i,t,y,%
d) Error
Show Answer

25) <script type="text/javascript" language="javascript">

qpt=((45%2)==0)? "hello" : "bye";
document.write(qpt);


</script>
a) hello
b) bye
c) Error in string handling
d) None of the above
Show Answer

26)<script language="javascript">
function x()
{
var qpt = "QualityPointTechnologies";
var pattern = new RegExp("POIiNT","i");
document.write(qpt.match(pattern));
}
</script>
a) Error
b) POIiNT
c) Point
d) null
Show Answer

27) How do you create a new object in JavaScript?
a) var obj = {};
b) var obj = Object();
c) var obj=new {};
d) None of the above
Show Answer

28) In Javascript, What does isNaN function do ?
a) Return true if the argument is not a number.
b) Return false if the argument is not a number.
c) Return true if the argument is a number.
d) None of the above
Show Answer

29) If x=103 & y=9 then x%=y , what is the value of x after executing x%=y?
a) 4
b) 3
c) 2
d) 5
Show Answer

30) Choose the external object:
a) Date
b) Option
c) Layer
d) Checkbox
Show Answer

31) Choose the four symbol pairs that represent RegExp properties lastMatch, lastParent, leftContext, and rightContext, respectively:
a) $&, $+, $`, $'
b) $+, $&, $', $`
c) $&, $~, $`, $'
d) $+, $&, $`, $'
Show Answer

32) Which of the following properties hold the values of the pixels of the length of the width and height of the viewer's screen resolution?
a) screen.width and screen.height
b) Resolution.width and Resolution.height
c) screen.pixels.width and screen.pixels.height
d) ViewerScreen.width and ViewerScreen.height
Show Answer

33) ParseInt(“15”,10)=?
a) 15
b) 10
c) 151
d) 150
Show Answer

34) Which JavaScript feature uses JAR files?
a) Object signing
b) Style sheets
c) Netcaster channels
d) Image rollovers
Show Answer

35)How to assign a function to a variable with the JavaScript Function contructor ?
a) var f=Function("x","y","return x+y");
b) var f=Function(x,y){ return x+y;}
c) var f= new Function("x", "y", "return x + y");
Show Answer

36) In JavaScript, Window.alert() is used to allow user to enter something
a) True
b) False
c) None of above
Show Answer

37) <script language="javascript">
function x()
{
var qpt = "We are fast growing Software Company located in Chennai, India.";
var pattern = new RegExp("in","gi");

document.write(pattern.exec(qpt) + " ");
document.write(pattern.exec(qpt) + " ");
document.write(pattern.exec(qpt) + " ");
}

</script>

a) in in In
b) in in in
c) in in null
d) in null null
Show Answer

38) Is Javascript has any date data type?
a) Yes
b) No
Show Answer

39) Math. round(-20.5)=?
a) -21
b) 20
c) -20
d) 21
Show Answer

40) ?_name is it valid javascript identifier?
a) Yes
b) No
Show Answer

41) <script language="javascript">
function x()
{
var qpt = "First come, first served";
var pattern = /first/gi;
document.write(qpt.match(pattern)[1]);
}
</script>

a) first
b) undefined
c) First
d) Error
Show Answer

42) (a). // , /* ...... **/
(b). / , /** ......./ , /*
(c). /*......*/ , //
(d). \*......*\ , //

In javascript, Which of the above Comments lines are used ?
a) Only (d)
b) Only (c)
c) Either (c) or (d)
d) Only (b)
Show Answer

43) <script language="javascript">
function x()
{
var s = "Give 100%!{[!!";
var pattern = /\W/g;
var output = s.match(pattern);
document.write(output);
}
</script>
a) ,%,!,{,[,!,!
b) G,i,v,e,1,0,0
c) Give 100
d) Error
Show Answer

44) Which best describes void?
a) A method
b) A function
c) A statement
d) An operator
Show Answer

45) <script type="text/javascript" language="javascript">
var qpt="QualityPointTechnologies";
var result =qpt.lastIndexOf("l");
document.write(result);
</script>
a) 3
b) 18
c) 17
d) 19
Show Answer

46) <script language="javascript">
function x()
{
var qpt = "First come, first served";
var pattern = /first/g;
document.write(qpt.match(pattern)[1]);
}
</script>
a) first
b) First
c) undefined
d) None of the above
Show Answer

47) <script language="javascript">
function sum(x)
{
function add(y)
{
return x+y;
}
return add;
}
function callme() { result=sum(5)(5); alert(result); }
</script>

If you call the function callme(), what will happen ?
a) 10
b) Error in calling Function
c) 5
d) None of the above
Show Answer

48) Who invented the javascript programming language?
a) Tennis Ritchie
b) James Gosling
c) Brendan Eich
Show Answer

49) <script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
Can you write HTML tag inside the javascript ?
a) No
b) Yes
c) Impossible
Show Answer

50) Which feature is supported in MSIE 3.x?
a) split()
b) document.clear()
c) join()
d) charAt()
Show Answer

51) How to speicfy the color of the hypertext links with JavaScript ?
a) document.linkColor="#00FF00";
b) document.LColor="#00FF00";
c) document.LinkC="#00FF00";
d) document.hyperTextLink="#00FF00":
Show Answer

52) <script language="javascript">
function x()
{
var qpt = "QualityPointTechnologies";
var pattern = /point/;

var output= qpt.search(pattern);

document.write("Position: " + output);
}
</script>
a) Position-7
b) Position-1
c) null
d) error
Show Answer

53) --------------- method returns the number of milliseconds in a date string.
a) setHours()
b) setMinutes()
c) parse()
Show Answer

54) ------------- converts a string to floating point numbers.
a) eval
b) ParseInt
c) ParseFloat
d) None
Show Answer

55) ---------------------- attempts to evaluate a string representing any javascript literals or variables, converting it to a number.
a) eval
b) parseFloat
c) parseInt
d) None
Show Answer

56) Which is not an attribute of the cookie property?
a) path
b) host
c) secure
d) domain
Show Answer

57) How do substring() and substr() differ?
a) One is not a method of the String object.
b) substr() takes three arguments, substring() only two.
c) Only one accepts a desired string length as an argument.
d) Besides the spelling, nothing.
Show Answer

58) Which is not a reserved word?
a) interface
b) short
c) program
d) throws
Show Answer

59) In Javascript, Which of the following method is used to find out the character at a position in a string?
a) charAt()
b) CharacterAt()
c) CharPos()
d) characAt()
Show Answer

60) <script type="text/javascript" language="javascript">

var qpt = "QualityPointTechnologies";
var result =qpt.substring(7,8);
document.write(result);

</script>
a) Po
b) yP
c) oi
d) P
Show Answer

61) How do you delete an element from an options array?
a) Set it to false.
b) Set it to null.
c) Set it to undefined.
d) Set it to -1
Show Answer

62) Is javaScript case sensitive ?
a) Yes
b) No
Show Answer

63) JavaScript RegExp Object has modifier 'i' to __________
a) Perform case-sensitive matching
b) Perform case-insensitive matching
c) Perform both case-sensitive&case-insensitive matching
Show Answer

64) What are the following looping structures are available in javascripts?
a) for,forecach
b) foreach,whileloop
c) do-while loop,foreach
d) for , while loop
Show Answer

65) Which of these is not a method of the Math object?
a) atan()
b) atan2()
c) eval()
d) acos()
Show Answer

66) <script type="text/javascript">
var s = "9123456 or 80000?";
var pattern = /\d{4}/;
var output = s.match(pattern);
document.write(output);
</script>
a) 9123
b) 91234
c) 80000
d) None of the above
Show Answer

67) In javascript, RegExp Object Method test() is used to search a string and returns _________
a) true or false
b) found value
c) index
d) None of the above
Show Answer

68) What property would you use to redirect a visitor to another page?
a) document.URL
b) window.location.href
c) .document.location.href
d) link.href
Show Answer

69) a.) var qpt="Quality Point Technologies";

b.) var qpt=new String("Quality Point Technologies");

Question:
In javascript, which of the above statement can used for string declaration ?

a) Either (a) or (b)
b) Only (a)
c) Neither (a) nor (b)
d) Only (b)
Show Answer

70) <script type="text/javascript" language="javascript">
var qpt = "QualityPointTechnologies";
var result =qpt.indexOf("Tech");
document.write(result);
</script>
a) 11
b) 12
c) 15
d) 13
Show Answer

71) <script language="javascript">
function x()
{
var s = "Eat to live, but do not live to eat";
var pattern = new RegExp("eat$");
document.write(pattern.exec(s));
}
</script>
a) Eat
b) eat
c) undefined
d) Eat eat
Show Answer

72) <script language="javascript">
function x()
{
var qpt = "We are fast growing Software Company located in Chennai, India.";
var pattern = new RegExp("in","g");

document.write(pattern.exec(qpt) + " ");
document.write(pattern.exec(qpt) + " ");
document.write(pattern.exec(qpt) + " ");
}

</script>
a) in in In
b) in in in
c) in in null
d) in null null
Show Answer

73) -------------- method is used to remove focus from the specified object.
a) blur()
b) focus()
c) None
Show Answer

74) parseFloat(“FF2”)=?
a) 152
b) FF2
c) NaN
d) None
Show Answer

75)eval((20*4)=?
a) Nan
b) 204
c) 24
d) 80
Show Answer

76)<script language="javascript">
function x()
{
var qpt = "QualityPointTechnologies";
var pattern = new RegExp("TECHNOLOGIES","i");
document.write(qpt.match(pattern));
}
</script>
a) null
b) Technologies
c) TECHNOLOGIES
d) Error
Show Answer

77)Javascript is a ________ typed language.
a) tightly
b) loosely
Show Answer

Answers

(1) a (2) c (3) a (4) a (5) a (6) a (7) c (8) c (9) c (10) d
(11) a (12) c (13) b (14) a (15) a (16) b (17) b (18) b (19) c (20) c
(21) d (22) a (23) a (24) b (25) b (26) d (27) a (28) a (29) a (30) d
(31) a (32) a (33) a (34) a (35) c (36) b (37) a (38) b (39) c (40) b
(41) a (42) b (43) a (44) d (45) b (46) c (47) a (48) c (49) b (50) d
(51) a (52) b (53) c (54) c (55) a (56) b (57) c (58) c (59) a (60) d
(61) b (62) a (63) b (64) d (65) c (66) a (67) a (68) b (69) a (70) b
(71) b (72) c (73) a (74) c (75) d (76) b (77) b

No comments:

Search This Blog