Instruction
- Total number of questions : 30.
- Time alloted : 30 minutes.
- Each question carry 1 mark.
- No Negative marks
- DO NOT refresh the page.
- All the best :-).
1. |
JavaScript can be written |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: None |
2. |
The snippet that has to be used to check if “a” is not equal to “null” is |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The not-equal operator !== compares o to null and evaluates to either true or false. |
3. |
Among the following, which one is a ternary operator? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: JavaScript supports one ternary operator, the conditional operator ?:, which combines three expressions into a single expression. |
4. |
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) ? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: When a switch executes, it computes the value of expression and then looks for a case label whose expression evaluates to the same value (where sameness is determined by the === operator). |
5. |
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? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: Instead of exiting a loop like the break keyword, the continue keyword moves to the next iteration from the place encountered. |
6. |
The purpose of extensible attribute is to |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The purpose of the extensible attribute is to be able to “lock down” objects into a known state and prevent outside tampering. |
7. |
The primary purpose of the array map() function is that it |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The map() method passes each element of the array on which it is invoked to the functionyou specify, and returns an array containing the values returned by that function. |
8. |
Which of the following is the correct code for invoking a function without this keyword at all, and also too determine whether the strict mode is in effect? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The above code defines and invokes a function to determine if we’re in strict mode. |
9. |
What is the difference between the two lines given below ? !!(obj1 && obj2); |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: None. |
10. |
What is the opposite approach to the lexical scoping? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The opposite approach to the lexical scoping is the dynamic scoping. |
11. |
If A is the superclass and B is the subclass, then subclass inherting the superclass can be represented as |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The subclass B inherits the prototype of the class A. |
12. |
What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: It is implementation-dependent whether classes defined by the host environment (such as the web browser) can be augmented using Object.prototype. In many web browsers, for example, you can add methods to HTMLElement.prototype and those methods will be inherited by the objects that represent the HTML tags in the current document. |
13. |
The properties() method is a |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: The properties() method is a non-enumerable method. |
14. |
The method that performs the search-and-replace operation to strings for pattern matching is |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The replace() method performs a search-and-replace operation. It takes a regular expression as its first argument and a replacement string as its second argument. |
15. |
Which is the object that defines methods that allow complete control over page content? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: The client-side document object defines methods that allow complete control over page content. |
16. |
Which looping statement allows XML tags to appear in JavaScript programs and adds API for operating on XML data? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option C Explanation: The for/each loop is a new looping statement standardized by E4X. E4X (ECMAScript for XML) is a language extension that allows XML tags to appear literally in JavaScript programs and adds syntax and API for operating on XML data. |
17. |
Which of the following is an example to perform the most common XML manipulations using the XML objects invocation? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: E4X is designed so that you can perform most common XML manipulations using language syntax. E4X also defines methods you can invoke on XML objects. Here, for example, is the insertChildBefore() method: pt.insertChildBefore(pt.element[1],<element id="1"><name>Deuterium</name></element>); |
18. |
What is the method used to pause “data” events? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: The above code snippet is used to pause data events, for throttling uploads, e.g. |
19. |
What does Rhino do when the getter and setter methods exist? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Rhino allows JavaScript code to query and set the static fields of Java classes and the instance fields of Java objects. Java classes often avoid defining public fields in favor of getter and setter methods. When getter and setter methods exist, Rhino exposes them as JavaScript properties. |
20. |
Why does Node not block while waiting for operations to complete? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: Because Node’s functions and methods are asynchronous, they do not block while waiting for operations to complete. |
21. |
What is the lifetime of the data stored through localStorage? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: Data stored through localStorage is permanent: it does not expire and remains stored on the user’s computer until a web app deletes it or the user asks the browser (through some browser-specific UI) to delete it. |
22. |
What will be done if more than one page requires a file of JavaScript code? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: If a file of JavaScript code is shared by more than one page, it only needs to be downloaded once, by the first page that uses it—subsequent pages can retrieve it from the browser cache. |
23. |
When will the window property come into play? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The Window object has a property named window that always refers to itself. You can use this property if you need to refer to the window object itself, but it is not usually necessary to use window if you just want to refer to access properties of the global window object. |
24. |
What is the code snippet to change the class and let the stylesheet specify the details? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: The above code snippet changes the class and lets the stylesheet specify the details. |
25. |
Which of the following framework was used by Google for Gmail? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The Closure library is the client-side library that Google uses for Gmail, Google Docs, and other web applications. This library is intended to be used with the Closure compiler, which strips out unused library functions. |
26. |
What will happen if we call setTimeout() with a time of 0 ms? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: If you call setTimeout() with a time of 0 ms, the function you specify is not invoked right away. Instead, it is placed on a queue to be invoked “as soon as possible” after any currently pending event handlers finish running. |
27. |
Why is the replace() method better than the assign() method? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option D Explanation: The replace() method is similar, but it removes the current document from the browsing history before loading the new document. When a script unconditionally loads a new document, the replace() method is often a better choice than assign(). |
28. |
Which is the preferred testing nowadays for scripting? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: In the past, the Navigator object was commonly used by scripts to determine if they were running in Internet Explorer or Netscape. This “browser-sniffing” approach is problematic because it requires constant tweaking as new browsers and new versions of existing browsers are introduced. Today, feature testing is preferred: rather than making assumptions about particular browser versions and their features, you simply test for the feature (i.e., the method or property) you need. |
29. |
Which is the property of a Window object that holids the name of the frame? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option A Explanation: The name property of a Window object holds the name of the frame, if it has one. This property is writable, and scripts can set it as desired. |
30. |
Which of the following can be used to select HTML elements based on the value of their name attributes? |
|||||||||||||||||||
Your Answer: Option (Not Answered) Correct Answer: Option B Explanation: To select HTML elements based on the value of their name attributes, you can use the getElementsByName() method of the Document object: var radiobuttons = document.getElementsByName("favorite_color"); |