

MCQOPTIONS
Saved Bookmarks
This section includes 302 Mcqs, each offering curated multiple-choice questions to sharpen your Javascript knowledge and support exam preparation. Choose a topic below to get started.
1. |
Consider the following code snippetfunction tail(o){for (; o.next; o = o.next) ;return o;}Will the above code snippet work? If not, what will be the error? |
A. | o, this will throw an exception as only numerics can be used in a for loop |
B. | o, this will not iterate |
C. | es, this will work |
D. | o, this will result in a runtime error with the message “Cannot use Linked List” |
Answer» D. o, this will result in a runtime error with the message “Cannot use Linked List” | |
2. |
Consider the following code snippetfunction printArray(a){var len = a.length, i = 0;if (len == 0)console.log("Empty Array");else{do{console.log(a[i]);} while (++i < len);}}What does the above code result? |
A. | rints the numbers in the array in order |
B. | rints the numbers in the array in the reverse order |
C. | rints 0 to the length of the array |
D. | rints “Empty Array” |
Answer» B. rints the numbers in the array in the reverse order | |
3. |
Consider the following statementsvar count = 0;while (count < 10){.log(count);count++;}In the above code snippet, what happens? |
A. | he values of count is logged or stored in a particular location or storage |
B. | he value of count from 0 to 9 is displayed in the console |
C. | n error is displayed |
D. | n exception is thrown |
Answer» C. n error is displayed | |
4. |
“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 |
A. | roperties |
B. | rototypes |
C. | value |
D. | efinition |
Answer» D. efinition | |
5. |
Which is a more efficient code snippet ?Code 1 :for(var=10;num>=1;num--){document.writeln(num);}Code 2 :var num=10;while(num>=1){document.writeln(num);num++;} |
A. | ode 1 |
B. | ode 2 |
C. | oth Code 1 and Code 2 |
D. | annot Compare |
Answer» B. ode 2 | |
6. |
Consider the following statementsvar text = "testing: 1, 2, 3"; // Sample textvar pattern = /d+/g // Matches all instances of one or more digitsIn order to check if the pattern matches with the string “text”, the statement is |
A. | ext==pattern |
B. | ext.equals(pattern) |
C. | ext.test(pattern) |
D. | attern.test(text) |
Answer» E. | |
7. |
Consider the following snippet codevar string1 = ”123”;var intvalue = 123;alert( string1 + intvalue )The result would be |
A. | 23246 |
B. | 46 |
C. | 23123 |
D. | xception |
Answer» D. xception | |
8. |
Identify the process done in the below code snippeto = {x:1, y:{z:[false,null,"]}};s = JSON.(o);p = JSON.parse(s); |
A. | bject Encapsulation |
B. | bject Serialization |
C. | bject Abstraction |
D. | bject Encoding |
Answer» C. bject Abstraction | |
9. |
Consider the below given syntaxbook[datatype]=assignment_value;In the above syntax, the datatype within the square brackets must be |
A. | n integer |
B. | String |
C. | n object |
D. | one of the mentioned |
Answer» C. n object | |
10. |
Consider the following code snippet :var book = {"main title": "JavaScript",'sub-title': "The Definitive Guide","for": "all audiences",author: {firstname: "David",surname: "Flanagan"}};In the above snippet, firstname and surname are |
A. | roperties |
B. | roperty values |
C. | roperty names |
D. | bjects |
Answer» D. bjects | |
11. |
Consider the following code snippetfunction f(o){if (o === undefined) debugger;}What could be the task of the statement debugger? |
A. | t does nothing but a simple breakpoint |
B. | t debugs the error in that statement and restarts the statement’s execution |
C. | t is used as a keyword that debugs the entire program at once |
D. | ll of the mentioned |
Answer» B. t debugs the error in that statement and restarts the statement’s execution | |
12. |
Consider the following code snippetwhile (a != 0){if (spam>a == 1)continue;else++;}What will be the role of the continue keyword in the above code snippet? |
A. | he continue keyword restarts the loop |
B. | he continue keyword skips the next iteration |
C. | he continue keyword skips the rest of the statements in that iteration |
D. | one of the mentioned |
Answer» D. one of the mentioned | |
13. |
Among the following, which one is a ternary operator? |
A. | + |
B. | : |
C. | – |
D. | ?: |
Answer» E. | |
14. |
What kind of an expression is “new Point(2,3)”? |
A. | Primary Expression |
B. | Object Creation Expression |
C. | Invocation Expression |
D. | Constructor Calling Expression |
Answer» C. Invocation Expression | |
15. |
JavaScript is a _______________ language |
A. | Object-Oriented |
B. | High-level |
C. | Assembly-language |
D. | Object-Based |
Answer» E. | |
16. |
A conditional expression is also called a |
A. | Alternate to if-else |
B. | Immediate if |
C. | If-then-else statement |
D. | None of the mentioned |
Answer» C. If-then-else statement | |
17. |
A statement block is a |
A. | conditional block |
B. | block that contains a single statement |
C. | Both conditional block and single statement |
D. | block that combines multiple statements into a single compound statement |
Answer» E. | |
18. |
The “var” and “function” are |
A. | Keywords |
B. | Declaration statements |
C. | Datatypes |
D. | Prototypes |
Answer» C. Datatypes | |
19. |
Consider the following statements switch(expression) { statements } In the above switch syntax, the expression is compared with the case labels using which of the following operator(s) ? |
A. | |
B. | equals |
C. | equal |
D. | |
Answer» E. | |
20. |
Consider the following statements var count = 0; while (count < 10) { console.log(count); count++; } In the above code snippet, what happens? |
A. | The values of count is logged or stored in a particular location or storage |
B. | The value of count from 0 to 9 is displayed in the console |
C. | An error is displayed |
D. | An exception is thrown |
Answer» C. An error is displayed | |
21. |
The enumeration order becomes implementation dependent and non-interoperable if : |
A. | If the object inherits enumerable properties |
B. | The object does not have the properties present in the integer array indices |
C. | The delete keyword is never used |
D. | Object.defineProperty() is not used |
Answer» B. The object does not have the properties present in the integer array indices | |
22. |
Consider the following code snippet function printArray(a) { var len = a.length, i = 0; if (len == 0) console.log("Empty Array"); else { do { console.log(a[i]); } while (++i < len); } }What does the above code result? |
A. | Prints the numbers in the array in order |
B. | Prints the numbers in the array in the reverse order |
C. | Prints 0 to the length of the array |
D. | Prints “Empty Array” |
Answer» B. Prints the numbers in the array in the reverse order | |
23. |
Consider the following code snippet function tail(o){ for (; o.next; o = o.next) ; return o; }Will the above code snippet work? If not, what will be the error? |
A. | No, this will throw an exception as only numerics can be used in a for loop |
B. | No, this will not iterate |
C. | Yes, this will work |
D. | No, this will result in a runtime error with the message “Cannot use Linked List” |
Answer» D. No, this will result in a runtime error with the message “Cannot use Linked List” | |
24. |
One of the special feature of an interpreter in reference with the for loop is that |
A. | Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property |
B. | The iterations can be infinite when an interpreter is used |
C. | The body of the loop is executed only once |
D. | All of the mentioned |
Answer» B. The iterations can be infinite when an interpreter is used | |
25. |
What will happen if the body of a for/in loop deletes a property that has not yet been enumerated? |
A. | The property will be stored in a cache |
B. | The loop will not run |
C. | That property will not be enumerated |
D. | All of the mentioned |
Answer» D. All of the mentioned | |
26. |
Consider the following code snippet while (a != 0) { if (a == 1) continue; else a++; } What will be the role of the continue keyword in the above code snippet? |
A. | The continue keyword restarts the loop |
B. | The continue keyword skips the next iteration |
C. | The continue keyword skips the rest of the statements in that iteration |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
27. |
Local Browser used for validations on the Web Pages uses __________. |
A. | Java |
B. | HTML |
C. | CSS |
D. | JS |
Answer» E. | |
28. |
JavaScript is also called as _____________. |
A. | Server Side Scripting Language |
B. | Browser Side Scripting Language |
C. | Client Side Scripting Language |
D. | Both B and C |
Answer» E. | |
29. |
Why JavaScript is called as Lightweight Programming Language ? |
A. | because JS is available free of cost |
B. | because JS is client side scripting |
C. | because we can add programming functionality inside JS |
D. | because JS can provide programming functionality inside but up to certain extend. |
Answer» E. | |
30. |
JavaScript Code is written inside file having extension __________. |
A. | .jvs |
B. | .javascript |
C. | .js |
D. | .jsc |
Answer» D. .jsc | |
31. |
Cost for Using JavaScript in your HTML is _________ . |
A. | Its Free !!! |
B. | $10 / Year |
C. | $15 / Year |
D. | $5 / Year |
Answer» B. $10 / Year | |
32. |
JavaScript is designed for following purpose - |
A. | To Style HTML Pages |
B. | To add interactivity to HTML Pages. |
C. | To Perform Server Side Scripting Opertion |
D. | To Execute Query Related to DB on Server |
Answer» C. To Perform Server Side Scripting Opertion | |
33. |
Javascript is _________ language. |
A. | Programming |
B. | Application |
C. | None of These |
D. | Scripting |
Answer» E. | |
34. |
What would be the output of the following fraction of code ? int Integer = 34 ; char String = 'S' ; System.out.print( Integer ) ; System.out.print( String ) ; |
A. | Does not compile as Integer and String are API class names. |
B. | 34 |
C. | S |
D. | 34 S |
Answer» E. | |
35. |
What will be output of the following program code? public class Test{ public static void main(String[] a) { short x = 10; x = x*5; System.out.print(x); } } |
A. | 50 |
B. | 10 |
C. | Compilation Error |
D. | None of these |
Answer» D. None of these | |
36. |
The following fraction of code double STATIC = 2.5 ; System.out.println( STATIC ); |
A. | Prints 2.5 |
B. | Rraises an error as STATIC is used as a variable which is a keyword |
C. | Raises an exception |
D. | None of these |
Answer» B. Rraises an error as STATIC is used as a variable which is a keyword | |
37. |
A proper scripting language is a |
A. | High level programming language |
B. | Assembly level programming language |
C. | Machine level programming language |
D. | Low level programming language |
Answer» B. Assembly level programming language | |
38. |
Which environment variable must the user enable in order to enable data tainting? |
A. | ENABLE_TAINT |
B. | MS_ENABLE_TAINT |
C. | NS_ENABLE_TAINT |
D. | ENABLE_TAINT_NS |
Answer» D. ENABLE_TAINT_NS | |
39. |
Which tag can handle mouse events in Netscape? |
A. | img |
B. | a |
C. | br |
D. | none of the mentioned |
Answer» B. a | |
40. |
What will the file_get_contents() return? |
A. | Server’s response |
B. | Errors |
C. | Exception |
D. | Client’s response |
Answer» B. Errors | |
41. |
What is the purpose of the file_get_contents()? |
A. | To get the errors and exceptions |
B. | To get the client’s response |
C. | To get the server’s response |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
42. |
What is the purpose of getting the paramerer fvonly? |
A. | To repeat the view test |
B. | To get the first view |
C. | To debug the code |
D. | None of the mentioned |
Answer» C. To debug the code | |
43. |
What will happen if you set the private flag as 1? |
A. | Test will be run only by the administrator |
B. | Test will not be run |
C. | Test is public |
D. | Test is not displayed in public |
Answer» E. | |
44. |
What is the purpose of the method par()? |
A. | Makes the text vertical |
B. | Makes the text horizontal |
C. | Makes the text diagonal |
D. | None of the mentioned |
Answer» C. Makes the text diagonal | |
45. |
What is the purpose of the method symbols in R? |
A. | Draw symbols |
B. | Draw other shapes |
C. | Draw symbols and other shapes |
D. | None of the mentioned |
Answer» C. Draw symbols and other shapes | |
46. |
What is the purpose of the method plot()? |
A. | Displays symbols |
B. | Displays charts |
C. | Displays symbols and charts |
D. | None of the mentioned |
Answer» C. Displays symbols and charts | |
47. |
Which function is used to create data frames? |
A. | data.frames() |
B. | frame.data() |
C. | data.frame() |
D. | frame(data) |
Answer» D. frame(data) | |
48. |
Which of the following list contains multiple data types? |
A. | Vectors |
B. | Data frames |
C. | Matrices |
D. | None of the mentioned |
Answer» C. Matrices | |
49. |
Which is the function used to add the vectors? |
A. | c() |
B. | add(vectors) |
C. | c(vectors) |
D. | vectors.add |
Answer» B. add(vectors) | |
50. |
Which of the following is the assignment operator? |
A. | <- |
B. | -> |
C. | = |
D. | |
Answer» B. -> | |