Javascript Design Patterns/Javascript Design Patterns Mcq Question Set 2 Sample Test,Sample questions

Question:
 "An expression that can legally appear on the left side of an assignment expression." is a well known explanation for variables, properties of objects, and elements of arrays. They are called_____.

1.Properties

2.Prototypes

3.Definition

4.Lvalue


Question:
 In JavaScript the x===y statement implies that:

1.Both x and y are equal in value, type and reference address as well.

2.Both are x and y are equal in value only.

3.Both are equal in the value and data type.

4.Both are not same at all.


Question:
 Which of the following is the correct output for the following JavaScript code:

function display1(option)  
{  
    return(option ?  "true" :  "false");  
}  
    bool ans=true;  
console.log(display1(ans));  

1.False

2.True

3.Runtime error

4.compilation error


Question:
 Which of the following number object function returns the value of the number?

1.toString()

2.valueOf()

3.toLocaleString()

4.toPrecision()


Question:
 Which of the following one is the property of the primary expression:

1.Contains only keywords

2.basic expressions containing all necessary functions

3.contains variable references alone

4.stand-alone expressions


Question:
 Which one of the following is correct output for the following given JavaScript code:

string  X= "Good";  
string  Y="Evening";  
alert(X+Y);  

1.Good

2.Evening

3.GooodEvening

4.Undefined


Question:
Choose the correct snippet from the following to check if the variable "a" is not equal the "NULL":

1.if(a!==null)

2.if (a!)

3.if(a!null)

4.if(a!=null)


Question:
Consider the following snippet of JavaScript code:

var text ="testing: 1, 2, 3";// Sample text  
var pattern =/d+/g// Matches all instances of one or more digits  
Which one of the following statement is most suitable to check if the pattern matches with the sting "text".

1.test(text)

2.equals(pattern)

3.test(pattern)

4.text==pattern


Question:
f the following piece of JavaScript code is executed, will it work if not, what kind of possible error can occur?

function fun(o)  
{  
for(;o.next; oo =o.next);  
return o;  
}  

1.Yes, it will work fine

2.No, this will not iterate at all

3.No, it will throw an exception as only numeric's can be used in a for loop

4.No, it will produce a runtime error with the message "Cannot use Linked List"


Question:
Find out the correct output of the following given piece of code from the given options:

functionfun()  
{  
int y=10;  
char z=10;  
if(y.tostring()===z)  
returntrue;  
else  
returnfalse;  
}  

1.logical error

2.false

3.runtime error

4.True


Question:
In a case, where the value of the operator is NULL , the typeof returned by the unary operator is___.

1.undefined

2.string

3.boolean

4.Object


Question:
In JavaScript, what is a block of statement?

1.Conditional block

2.block that combines a number of statements into a single compound statement

3.both conditional block and a single statement

4.block that contains a single statement


Question:
In JavaScript, what will be used for calling the function definition expression:

1.Function prototype

2.Function literal

3.Function calling

4.Function declaration


Question:
In the following given syntax of the switch statement, the Expression is compared with the labels using which one of the following operators?

switch(expression)  
{  
    statements  
}  

1.===

2.equals

3.==

4.equals


Question:
n the JavaScript, which one of the following is not considered as an error:

1.Syntax error

2.Missing of semicolons

3.Division by zero

4.Missing of Bracket


Question:
See the given code of JavaScript and choose the correct output from the following:

var string1 = "40";  
varvalueinit=50;  
alert( string1 +intvalue);  

1.4090

2.90

3.4050

4.Exceptions


Question:
Suppose we have a text "human" that we want to convert into string without using the "new" operator. Which is the correct way from the following to do so:

1.toString()

2.String(human)

3.String newvariable="human"

4.Both human.toString() and String(human)


Question:
The "function" and " var" are known as:

1.Keywords

2.Data types

3.Declaration statements

4.Prototypes


Question:
The "new Point(3,2)", is a kind of _______ expression

1.Object Creation Expression

2.Primary Expression

3.Invocation Expression

4.Constructor Calling Expression


Question:
The amount of scenario interaction is related to which of the following metrics?

1.Structural Complexity

2.Coupling

3.Cohesion

4.All of the Mentioned


Question:
What are the three important manipulations for a loop on a loop variable?

1.Updation, Incrementation, Initialization

2.Initialization, Testing, Incrementation

3.Testing, Updation, Testing

4.Initialization, Testing, Updation


Question:
What is the role of the "continue" keyword in the following piece of JavaScript code?

while (x !=0)  
{  
if(x ==1)  
continue;  
else  
       x++;  
}  

1.The continue keyword restarts the loop

2.The continue keyword skips the next iteration

3.The "continue" keyword breaks out of the loop

4.It is used for skipping the rest of the statements in that particular iteration


Question:
What we will get if we compare the "one" with "8" using the less than operator ("one"<8)?

1.False

2.True

3.NaN

4.Undefined


Question:
What will be the output of the following JavaScript code?

functioncomparison()  
{  
int number=10;  
if(number==="10")  
returntrue;  
else  
returnfalse;  
}  

1.True

2.false

3.runtime error

4.compilation error


Question:
What will happen, if the following JavaScript code is executed?

var count =0;  
while (count <10)  
{  
     console.log(count);  
     count++;  
}  

1.An error is displayed

2.An exception is thrown

3.The values of count variable are logged or stored in a particular location or storage

4.The value of count from 0 to 9 is displayed in the console


Question:
When interpreter encounters an empty statements, what it will do:

1.Shows a warning

2.Prompts to complete the statement

3.Throws an error

4.Ignores the statements


Question:
When there is an indefinite or an infinite value during an arithmetic computation in a program, then JavaScript prints______.

1.Prints an exception error

2.Prints an overflow error

3.Displays "Infinity"

4.Prints the value as such


Question:
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?

1.slice()

2.split()

3.substr()

4.search()


Question:
Which of the following givenfunctions of the Number Object formats a number with a different number of digits to the right of the decimal?

1.toExponential()

2.toFixed()

3.toPrecision()

4.toLocaleString()


Question:
Which of the following is correct?

1.The purpose of assigning weights is to resolve the situation is which first architecture scores better in the other half

2.The purpose of assigning weights is to resolve the situation is which second architecture score well on one half of the scenario

3.All of the mentioned

4.None of the mentioned


Question:
Which of the following is the correct output for the following JavaScript code:

varx=5,y=1  
var obj ={ x:10}  
with(obj)  
{  
      alert(y)  
}  

1.1

2.Error

3.10

4.5


Question:
Which of the following option is used as hexadecimal literal beginning?

1.00

2.0x

3.0X

4.Both 0x and 0X


Question:
Which of the following type of a variable is volatile?

1.Mutable variable

2.Dynamic variable

3.Volatile variable

4.Immutable variable


Question:
Which one of the following also known as Conditional Expression:

1.Alternative to if-else

2.Switch statement

3.If-then-else statement

4.immediate if


Question:
Which one of the following is an ternary operator:

1.?

2.:

3.-

4.+


Question:
Which one of the following is correct output for the following given JavaScript code

<p id="demo"></p>  
<script>  
functionmyFunction()  
{  
document.getElementById("demo").innerHTML=Math.acos(0.5);  
}  
</script>  

1.01

2.4

3.00

4.047


Question:
Which one of the following is correct output for the following given JavaScript code:

<p id="demo"></p>  
<script>  
function Function1()  
{  
document.getElementById("demo").innerHTML=Math.cbrt(792);  
}  
</script>  

1.972

2.81

3.9

4.Error


Question:
Which one of the following is correct output for the following given JavaScript code:

<p id="demo"></p>  
<script>  
functionourFunction()  
{  
document.getElementById("demo").innerHTML=Math.abs(-7.25);  
}  
</script>  

1.7

2.-7.25

3.25

4.-7


Question:
Which one of the following is correct output for the following given JavaScript code:

functionheight()  
{     
var  height=123.56;  
var type =(height>=190)?"Taller":"Little short";  
return type;  
}  

1.123.56

2.Taller

3.190

4.Little shorter


Question:
Which one of the following is correct output for the following given JavaScript code:

functionoutputfun(object)  
{  
    var place=object ?object.place: "Italy";  
    return "clean:"+ place;  
}  
console.log(outputfun({place:India}));  

1.Error

2.clean:Italy

3.clean:India

4.Undefined


Question:
Which one of the following is correct output for the following given JavaScript code:

var  obj=  
{  
    length:20,  
    height:35,  
}  
if('breadth' in obj === false)   
{  
    obj.breadth = 12;  
}  
   
console.log(obj.breadth);  

1.Error

2.Undefined

3.12

4.20


Question:
Which one of the following is correct output for the following javascriptcode:

var string1 = "Letsfindout";  
 var intvalue = 40;  
 alert( string1 + intvalue );  

1.Letsfindout 40

2.40

3.Letsfindout40

4.Exceptions


Question:
Which one of the following is known as the Equality operator, which is used to check whether the two values are equal or not:

1.=

2.===

3.==

4.&&


Question:
Which one of the following is not a keyword:

1.if

2.with

3.debugger

4.use strict


Question:
Which one of the following is not considered as "statement" in the JavaScript?

1.use strict

2.debugger

3.if

4.with


Question:
Which one of the following is the correct way for calling the JavaScript code?

1.Preprocessor

2.Triggering Event

3.RMI

4.Function/Method


Question:
Which one of the following is used for the calling a function or a method in the JavaScript:

1.Property Access Expression

2.Functional expression

3.Invocation expression

4.Primary expression


Question:
Which one of the following operator is used to check weather a specific property exists or not:

1.Exists

2.exist

3.within

4.in


Question:
Which one of the following operator returns false if both values are equal?

1.!

2.!==

3.!=

4.All of the above


Question:
Which type of JavaScript language is ___

1.Object-Oriented

2.Object-Based

3.Assembly-language

4.High-level


More MCQS

  1. Javascript Design Patterns Mcq Question Set 1
  2. Javascript Design Patterns Mcq Question Set 2
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!