Olete.in
Articles
Mock Tests
🧪 Javascript Design Patterns MCQ Quiz Hub
Javascript Design Patterns Mcq Question Set 2
Choose a topic to test your knowledge and improve your Javascript Design Patterns skills
1. The amount of scenario interaction is related to which of the following metrics?
Structural Complexity
Coupling
Cohesion
All of the Mentioned
2. Which of the following is correct?
The purpose of assigning weights is to resolve the situation is which first architecture scores better in the other half
The purpose of assigning weights is to resolve the situation is which second architecture score well on one half of the scenario
All of the mentioned
None of the mentioned
3. Which type of JavaScript language is ___
Object-Oriented
Object-Based
Assembly-language
High-level
4. 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
Error
10
5
5. Which one of the following also known as Conditional Expression:
Alternative to if-else
Switch statement
If-then-else statement
immediate if
6. In JavaScript, what is a block of statement?
Conditional block
block that combines a number of statements into a single compound statement
both conditional block and a single statement
block that contains a single statement
7. When interpreter encounters an empty statements, what it will do:
Shows a warning
Prompts to complete the statement
Throws an error
Ignores the statements
8. The "function" and " var" are known as:
Keywords
Data types
Declaration statements
Prototypes
9. 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 }
===
equals
==
equals
10. What will happen, if the following JavaScript code is executed? var count =0; while (count <10) { console.log(count); count++; }
An error is displayed
An exception is thrown
The values of count variable are logged or stored in a particular location or storage
The value of count from 0 to 9 is displayed in the console
11. Which one of the following is the correct way for calling the JavaScript code?
Preprocessor
Triggering Event
RMI
Function/Method
12. Which of the following type of a variable is volatile?
Mutable variable
Dynamic variable
Volatile variable
Immutable variable
13. Which of the following option is used as hexadecimal literal beginning?
00
0x
0X
Both 0x and 0X
14. When there is an indefinite or an infinite value during an arithmetic computation in a program, then JavaScript prints______.
Prints an exception error
Prints an overflow error
Displays &quot;Infinity&quot;
Prints the value as such
15. n the JavaScript, which one of the following is not considered as an error:
Syntax error
Missing of semicolons
Division by zero
Missing of Bracket
16. Which of the following givenfunctions of the Number Object formats a number with a different number of digits to the right of the decimal?
toExponential()
toFixed()
toPrecision()
toLocaleString()
17. Which of the following number object function returns the value of the number?
toString()
valueOf()
toLocaleString()
toPrecision()
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?
slice()
split()
substr()
search()
19. In JavaScript the x===y statement implies that:
Both x and y are equal in value, type and reference address as well.
Both are x and y are equal in value only.
Both are equal in the value and data type.
Both are not same at all.
20. Choose the correct snippet from the following to check if the variable "a" is not equal the "NULL":
if(a!==null)
if (a!)
if(a!null)
if(a!=null)
21. 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:
toString()
String(human)
String newvariable=&quot;human&quot;
Both human.toString() and String(human)
22. What will be the output of the following JavaScript code? functioncomparison() { int number=10; if(number==="10") returntrue; else returnfalse; }
True
false
runtime error
compilation error
23. 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; }
logical error
false
runtime error
True
24. See the given code of JavaScript and choose the correct output from the following: var string1 = "40"; varvalueinit=50; alert( string1 +intvalue);
4090
90
4050
Exceptions
25. In JavaScript, what will be used for calling the function definition expression:
Function prototype
Function literal
Function calling
Function declaration
26. Which of the following one is the property of the primary expression:
Contains only keywords
basic expressions containing all necessary functions
contains variable references alone
stand-alone expressions
27. 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".
test(text)
equals(pattern)
test(pattern)
text==pattern
28. Which one of the following is used for the calling a function or a method in the JavaScript:
Property Access Expression
Functional expression
Invocation expression
Primary expression
29. The "new Point(3,2)", is a kind of _______ expression
Object Creation Expression
Primary Expression
Invocation Expression
Constructor Calling Expression
30. Which one of the following operator is used to check weather a specific property exists or not:
Exists
exist
within
in
31. Which one of the following is an ternary operator:
?
:
-
+
32. "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_____.
Properties
Prototypes
Definition
Lvalue
33. 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));
False
True
Runtime error
compilation error
34. 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);
Error
Undefined
12
20
35. 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; }
123.56
Taller
190
Little shorter
36. Which one of the following is correct output for the following given JavaScript code: string X= "Good"; string Y="Evening"; alert(X+Y);
Good
Evening
GooodEvening
Undefined
37. 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}));
Error
clean:Italy
clean:India
Undefined
38. 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>
7
-7.25
25
-7
39. 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>
972
81
9
Error
40. 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>
01
4
00
047
41. What we will get if we compare the "one" with "8" using the less than operator ("one"<8)?
False
True
NaN
Undefined
42. Which one of the following is known as the Equality operator, which is used to check whether the two values are equal or not:
=
===
==
&amp;&amp;
43. Which one of the following operator returns false if both values are equal?
!
!==
!=
All of the above
44. In a case, where the value of the operator is NULL , the typeof returned by the unary operator is___.
undefined
string
boolean
Object
45. Which one of the following is correct output for the following javascriptcode: var string1 = "Letsfindout"; var intvalue = 40; alert( string1 + intvalue );
Letsfindout 40
40
Letsfindout40
Exceptions
46. Which one of the following is not a keyword:
if
with
debugger
use strict
47. What are the three important manipulations for a loop on a loop variable?
Updation, Incrementation, Initialization
Initialization, Testing, Incrementation
Testing, Updation, Testing
Initialization, Testing, Updation
48. 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; }
Yes, it will work fine
No, this will not iterate at all
No, it will throw an exception as only numeric&#039;s can be used in a for loop
No, it will produce a runtime error with the message &quot;Cannot use Linked List&quot;
49. What is the role of the "continue" keyword in the following piece of JavaScript code? while (x !=0) { if(x ==1) continue; else x++; }
The continue keyword restarts the loop
The continue keyword skips the next iteration
The &quot;continue&quot; keyword breaks out of the loop
It is used for skipping the rest of the statements in that particular iteration
50. Which one of the following is not considered as "statement" in the JavaScript?
use strict
debugger
if
with
Submit