Question: 01
Which of the following Javascript Regular Expression modifiers finds one or more occurrences of a specific character in a string?

a.    ?
b.    *
c.    +
d.    #


Question: 02
Analyze the following code snippet. What will be the output of this code?

<html>
<body>
<script type=”text/javascript”>
var str = “Visit Gardens(now)”;
var patt1 = new RegExp(“(now)”, “g”);
patt1.test(str);
document.write(RegExp.lastParen);
</script>
</body>
</html>

a.    now
b.    (now)
c.    15
d.    19


Question: 03
In an HTML page, the form tag is defined as follows:

<form onsubmit=”return Validate()” action=”http://www.mysite.com/”>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What will the validate() function look like?

a.    <script type=”text/javascript”>
function Validate()
{
if(document.forms[0].name.value == “”)
return true;
else
return false;}
</script>

b.    <script type=”text/javascript”>
function Validate()
{
if(document.forms[0].name.value == “”)
return false;
else
return true;
}
</script>

c.    <script type=”text/javascript”>
function Validate()
{
if(document.forms[0].name== “”)
return false;
else
return true;
}
</script>

d.    <script type=”text/javascript”>
function Validate()
{
if(document.forms[0].name == “”)
return true;
else
return false;
}
</script>


Question: 04
Which of the following methods is not a valid Array object method in JavaScript?

a.    reverse
b.    shift
c.    unshift
d.    splice
e.    All of the above are valid.


Question: 05
Consider the code snippet below. Which of the given options represents the correct sequence of outputs when this code is executed in E4X?

var p1 = <p>Kibology for all.</p>;
alert(p1.name().uri);
default xml namespace = ‘http://www.w3.org/1999/xhtml’;
var p2 = <p>Kibology for all.</p>;
alert(p2.name().uri);
default xml namespace = ”;
var p3 = <p>Kibology for all.</p>;
alert(p3.name().uri);

a.    ”,http://www.w3.org/1999/xhtml,”
b.    ”,”,”
c.    ”,http://www.w3.org/1999/xhtml,http://www.w3.org/1999/xhtml
d.    None of the above


Question: 06
Which of the following Javascript Regular Expression object methods is used to search a string for a specified value and return the result as true or false?

a.    exec()
b.    compile()
c.    return()
d.    test()


Question: 07
Which of the following is not a valid JavaScript operator?

a.    *=
b.    /=
c.    %=
d.    ^+


Question: 08
Analyze the following code snippet. What will be the output of this code?

<html>
<body>
<script type=”text/javascript”>
var str = “The drain of the plane is plain”;
var patt1 =/ain/g;
document.write(str.match(patt1));
</script>
</body>
</html>

a.    1
b.    ain
c.    7,29
d.    7
e.    ain,ain


Question: 09
Which of the following DOM objects can be used to determine the resolution of the screen?

a.    It is not possible to determine the resolution of the screen.
b.    Screen object
c.    Document object
d.    Window object
e.    None of the above


Question: 10
Which of the following statements regarding let in JavaScript is not correct?

a.    The let definition defines variables whose scope is constrained to the block in which they’re defined. This syntax is very much like the syntax used for var.

b.    The let expression lets you establish variables scoped only to a single expression.

c.    The let keyword provides a way to associate values with variables within the scope of a block, and affects the values of like-named variables outside the block.

d.    You can use let to establish variables that exist only within the context of a for loop.


Question: 11
Which of the following is not a valid String method?

a.    link()
b.    italics()
c.    str()
d.    sup()


Question: 12
Consider the following code snippet. Which of the given options would be used in E4X to change the color of the descendant node chair?

var element = <Home>
<Room>
<Furniture>
<chair color=”Brown”/>
</Furniture>
</Room>
</Home>

a.    element.chair.color=”light brown”
b.    element.chair.@color=”light brown”
c.    element..chair.@color=”light brown”


Question: 13
Which of the following Javascript Regular Expression Character Classes finds any non-digit character in a given string?

a.    \W
b.    \S
c.    \B
d.    \D


Question: 14
Which of the following is the correct syntax for using the Javascript exec() object method?

a.    RegExpObject.exec()
b.    RegExpObject.exec(string)
c.    RegExpObject.exec(parameter1,parameter2)
d.    None of the above


Question: 15
Which of the following results is returned by the JavaScript operator “typeof” for the keyword “null”?

a.    function
b.    object
c.    string
d.    number


Question: 16
Which of the following methods is used to add and/or remove elements from an array and modify them in place?

a.    push
b.    slice
c.    join
d.    splice


Question: 17
Which of the given options represents the correct length when alert(Emp..*.length()); is applied to the following code?

var Emp = <Emp>
<name>Mark</name>
<likes>
<os>Linux</os>
<browser>Firefox</browser>
<language>JavaScript</language>
<language>Python</language>
</likes>
</Emp>

a.    11
b.    5
c.    6
d.    12


Question: 18
Which of the following can be achieved using JavaScript?

a.    Reading or writing from external files
b.    Accessing or modifying browser settings
c.    Launching the default email application of the client
d.    All of the above can be achieved using JavaScript.


Question: 19
Consider the code below. What will be the final value of the variable “apt”?

var apt=2;
apt=apt<<2;

a.    2
b.    4
c.    6
d.    8
e.    16


Question: 20
Which of the following options can be used to delete a child node of an XML object in E4X?

a.    delete xmlobject.child;
b.    delete xmlobject.child[0];
c.    delete xmlobject.@attribute;
d.    All of the above


Question: 21
Which of the following can be used to create attribute values by placing variables and expressions within them?

a.    []
b.    ()
c.    {}
d.    <>


Question: 22
What is the output of the following JavaScript code?

s2 = new String(“2 + 2″)
document.write(eval(s2));

a.    4
b.    2+2
c.    Error
d.    None of the above


Question: 23
Analyze the following code using the source property of Regular Expressions. What will be the output of the below code snippet?

<html>
<body>
<script type=”text/javascript”>
var str = “Visit Garden\Showcase”;
var patt1 = new RegExp(“en\S”,”g”);
document.write(“The regular expression is: ” + patt1.source);
</script>
</body>
</html>

a.    The regular expression is: en\S
b.    The regular expression is: 11
c.    The regular expression is: enS
d.    The regular expression is: 10


Question: 24
Is the following statement true or false?

A function becomes a generator if it contains one or more yield statements.

a.    True
b.    False


Question: 25
Is the following statement regarding expression closures in JavaScript true or false?

The syntax function(x) {return x*x;} can be written as function(x) x*x.

a.    True
b.    False


Question: 26
What does the following JavaScript code do?

<html>
<body>
<script type=”text/javascript”>
function validate()
{
var chk=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”;
var ok=”yes”;
var temp;
var field1=document.getElementById(“t1″);
var field=field1.value.substring(field1.value.length-1,field1.value.length);
if(chk.indexOf(field)==”-1″)
{
alert(“error”);
field1.value=(field1.value).slice(0,field1.value.length-1);
}
}
</script>
<input type=”text” id=”t1″ onkeyup=”validate()” onkeypress =”validate()”/>
</body>
</html>

a.    The code will cause an error alert to be displayed if a numeric character is entered, and the numeric character is removed.

b.    The code will cause an error alert to be displayed if a non-numeric character is entered, and the non-numeric character is removed.

c.    The code will cause an error alert to be displayed if a numeric character is entered, and the value of textbox is reset.

d.    The code will cause an error alert to be displayed if a non-numeric character is entered, and the value of textbox is reset.


Question: 27
Which of the following objects is the top-level object in the JavaScript hierarchy?

a.    Navigator
b.    Screen
c.    Window
d.    Document


Question: 28
In JavaScript, the encodeURI() function is used to encode special characters. Which of the following special characters is/are an exception to that rule?

a.    £
b.    €
c.    @
d.    $
e.    a and b
f.    c and d


Question: 29
Which of the following is the correct way to create an XML object in E4X?

a.    var languages = new XML(‘<languages type=”dynamic”><lang>JavaScript</lang><lang>Python</lang></languages>’);

b.    var languages XML = new XML(‘<languages type=”dynamic”><lang>JavaScript</lang><lang>Python</lang></languages>’);

c.    var languages = <languages type=”dynamic”>
<lang>JavaScript</lang>
<lang>Python</lang>
</languages>;

d.    All of the above are correct.

e.    a and c

f.    b and c


Question: 30
Which of the following are not global methods and properties in E4X?

a.    ignoreComments
b.    ignoreWhiteSpace
c.    setName()
d.    setNamespace()
e.    a and b
f.    c and d


Question: 31
Which of the following is used to solve the problem of enumerations in JavaScript?

a.    let
b.    Regex
c.    Generators
d.    E4X


Question: 32
Which of the following is not a valid Date Object method in JavaScript?

a.    parse()
b.    setDay()
c.    setTime()
d.    valueOf()


Question: 33
Which of the following is the correct method for getting the date of February 1 of the current year into a variable called “newDate”?

a.    var d = new Date();
newDate=new Date(d.getFullYear(), 1, 2);

b.    var d = new Date();
newDate=new Date(d.getFullYear(), 2, 1);

c.    var d = new Date();
newDate=new Date(d.getFullYear(), 1, 1);

d.    var d = new Date();
newDate= (d.getFullYear(), 1, 1);


Question: 34
Which of the following options is used to access the attributes in E4X?

a.    @
b.    ::
c.    #
d.    *


Question: 35
Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?

a.    reduce()
b.    reduceRight()
c.    reverse()
d.    pop()


Question: 36
Which of the following is not a valid method in generator-iterator objects in JavaScript?

a.    send()
b.    throw()
c.    next()
d.    stop()


Question: 37
Analyze the following code snippet, which uses a Javascript Regular Expression Character Set. What will be the output of this code?

<html>
<body>
<script type=”text/javascript”>
var str = “Is this enough?”;
var patt1 = new RegExp(“[^A-J]“);
var result = str.match(patt1);
document.write(result);
</script>
</body>
</html>

a.    I
b.    Is
c.    s
d.    I,s,


Question: 38
Analyze the following code snippet. What will be the output of this code?

<html>
<body>
<script type=”text/javascript”>
var str = “The rose”;
var patt1 = new RegExp(“rose”, “g”);
patt1.test(str);
document.write(“rose found. index now at: ” + patt1.lastIndex);
</script>
</body>
</html>

a.    rose found. index now at: 5
b.    rose found. index now at: 4
c.    rose found. index now at: 8
d.    No output


Question: 39
Using the concept of “iterators” and “generators” in JavaScript, what will be the output of the following code?

function testGenerator()
{
yield “first”;
document.write(“step1″);
yield “second”;
document.write(“step2″);
yield “third”;
document.write(“step3″);
}
var g = testGenerator();
document.write(g.next());
document.write(g.next());

a.    firststep1second
b.    step1step2
c.    step1
d.    step1step2step3


Question: 40
Which of the following is the correct syntactical representation of a generator expression in JavaScript?

a.    var doubles = [i * 2 for (i in it)];
b.    var doubles = [i * 2 for [i in it]];
c.    var doubles = (i * 2 for (i in it));
d.    var doubles = {i * 2 for (i in it)};

Don't Miss A Single Updates

Remember to check your email account to confirm your subscription.

Blogger
Disqus
Post a comment ➜

No Comment