InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 101. |
What is the purpose of the DocumentFragment node type?(a) To hold a portion of a document(b) To split the document into fragments(c) To hold the entire document(d) To hold the fragments |
|
Answer» Correct option is (a) To hold a portion of a document The explanation: The DocumentFragment node type represents a “lightweight” Document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. |
|
| 102. |
The snippet that has to be used to check if “a” is not equal to “null” is _________(a) if(a!=null)(b) if (!a)(c) if(a!null)(d) if(a!==null) |
|
Answer» Correct option is (d) if(a!==null) To explain: A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. The more commonly-used abstract comparison (e.g. ==) converts the operands to the same type before making the comparison. The not-equal operator !== compares 0 to null and evaluates to either true or false. |
|
| 103. |
JavaScript Code can be called by using ___________(a) RMI(b) Triggering Event(c) Preprocessor(d) Function/Method |
|
Answer» The correct option is (d) Function/Method For explanation I would say: JavaScript code can be called by making a function call to the element on which JavaScript has to be run. There are many other methods like onclick, onload, and onsubmit etc. |
|
| 104. |
What is the command used for debugging output in Node?(a) print();(b) console.log(…);(c) debug(…);(d) execute(…); |
|
Answer» The correct answer is (b) console.log(…); Explanation: Console.log() prints the content in the argument on to the output screen. Node defines console.log() for debugging output like browsers do. |
|
| 105. |
JavaScript is a _______________ language.(a) Object-Oriented(b) High-level(c) Assembly-language(d) Object-Based |
|
Answer» The correct choice is (d) Object-Based Easiest explanation: JavaScript is not a full-blown OOP (Object-Oriented Programming) language, such as Java or PHP, but it is an object-based language. The criteria for object orientation are the classic threesome of polymorphism, encapsulation and inheritance and JavaScript doesn’t pass this. |
|
| 106. |
The type of a variable that is volatile is _______________(a) Volatile variable(b) Mutable variable(c) Immutable variable(d) Dynamic variable |
|
Answer» The correct option is (b) Mutable variable To explain: The variables whose values can be changed are called mutable variable types. In JavaScript, only objects and arrays are mutable, not primitive values. |
|
| 107. |
The C in CSS stands for _______________(a) Continuous(b) Cascaded(c) Contentional(d) Cascading |
|
Answer» Correct choice is (d) Cascading The best I can explain: The C in CSS stands for “cascading”. This term indicates that the style rules that apply to any given element in a document can come from a “cascade” of different sources. |
|
| 108. |
How do we define the term Thread?(a) Device that controls input(b) Variable that controls movement(c) Controlled execution of applications(d) Device that controls input & Variable that controls movement |
|
Answer» Correct answer is (c) Controlled execution of applications To explain I would say: Threads are sequential units of controlled execution for applications. A thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. |
|
| 109. |
Which of the following is a global object?(a) Register(b) Location(c) Window(d) Position |
|
Answer» Correct option is (c) Window Explanation: In client-side JavaScript, the Window object is also the global object. This means that the Window object is at the top of the scope chain and that its properties and methods are effectively global variables and global functions. |
|
| 110. |
How can you send data using a Worker object?(a) postMessage()(b) sendMessage()(c) Message()(d) post() |
|
Answer» Correct answer is (a) postMessage() The best I can explain: Once you have a Worker object, you can send data to it with postMessage(). The value you pass to postMessage() will be cloned, and the resulting copy will be delivered to the worker via a message event. postMessage() sends a message — which can consist of any JavaScript object — to the worker’s inner scope. |
|
| 111. |
What is the command to run the node programs?(a) node(program.js)(b) program.js(c) node program.js(d) node.program.js |
|
Answer» Correct answer is (c) node program.js For explanation I would say: The node programs can be run with the command:node program.js. The command can be written more simply like node program. |
|
| 112. |
The setTimeout() method is used to _______________(a) Make the event sleep(b) Register a function to be invoked after a certain time(c) Invoke an event after a certain time(d) Time for iteration |
|
Answer» Correct answer is (b) Register a function to be invoked after a certain time Easy explanation: The setTimeout(), which registers a function to be invoked after a specified amount of time. The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds. |
|
| 113. |
What is the JavaScript code snippet to find all container elements with class “reveal”?(a) var elements = document.getElementsByClassName(“reveal”);(b) var elements = document.getElementByClassName(“reveal”);(c) var elements = document.getElementByName(“reveal”);(d) var elements = document.getElementsClassName(“reveal”); |
|
Answer» Correct choice is (a) var elements = document.getElementsByClassName(“reveal”); The best I can explain: The getElementsByClassName() method returns a collection of all elements in the document with the specified class name, as a NodeList object. The above code snippet finds all container elements with class “reveal”. |
|
| 114. |
Which of the following is a global object for a new worker?(a) WorkerGlobalScope(b) Worker(c) WorkerScope(d) Window |
|
Answer» The correct answer is (a) WorkerGlobalScope The explanation is: A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page. The WorkerGlobalScope is the global object for a new worker, and it is what a worker thread looks like, on the inside, to itself. |
|
| 115. |
The object that looks to the thread that creates it is _______________(a) Window(b) Worker(c) Element(d) Hash |
|
Answer» Correct option is (b) Worker To explain: A web worker is a JavaScript running in the background, without affecting the performance of the page. The Worker object: this is what a worker looks like from the outside to the thread that creates it. |
|
| 116. |
In how many modes can the closure compiler be run?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Right answer is (b) 2 To explain: The Closure Compiler is a tool for making JavaScript download and run faster. There are totally 2 modes in which the closure compiler can be run namely: Simple mode Advanced mode. |
|
| 117. |
In what way is the closure compiler efficient?(a) Increases the size of the JavaScript files(b) Reduces the size of the JavaScript files(c) Reduces the execution time(d) Reduces the speed |
|
Answer» Correct answer is (b) Reduces the size of the JavaScript files Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs. |
|
| 118. |
Which Window object method is used to display a message in a dialog box?(a) alert()(b) prompt()(c) message()(d) console.log |
|
Answer» Right option is (a) alert() Explanation: The Window object defines methods like alert(), which displays a message in a dialog box. A prompt message can be displayed on the screen using alert(). |
|
| 119. |
When a program contains extensive use of event handlers, which of the following is necessary?(a) Modular functions(b) Nested functions(c) Split up programs(d) Global variables |
|
Answer» The correct option is (b) Nested functions The explanation is: Nested functions are those functions in which one function is defined inside another function. Nested functions are common in client-side JavaScript, because of its extensive use of event handlers. |
|
| 120. |
Why does the Node rely on event handlers?(a) APIs are synchronous(b) APIs are asynchronous(c) APIs are reusable(d) APIs are modular |
|
Answer» Correct answer is (b) APIs are asynchronous The best I can explain: For handling the spontaneous events occurring on the web page the event handlers are important. Because the APIs are asynchronous, Node relies on event handlers, which are often implemented using nested functions and closures. |
|
| 121. |
In which part does the form validation occur?(a) Client(b) Server(c) Both Client and Server(d) User side |
|
Answer» Right option is (b) Server Explanation: The data information from the client side is first sent to the server side. Form validation used to occur at the server after the client had entered all necessary data and then pressed the Submit button. |
|
| 122. |
Which property holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available?(a) dataTransfer(b) transferData(c) dataExchange(d) exchangeData |
|
Answer» The correct option is (a) dataTransfer For explanation: The property, dataTransfer, holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available. The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. |
|
| 123. |
In which way can the closure compiler can be used?(a) Open source(b) Run time application(c) Web application(d) Only Open source and Web application |
|
Answer» Correct answer is (d) Only Open source and Web application Easiest explanation: Closure compiler parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. You can use the Closure Compiler as: An open source Java application that you can run from the command line. A simple web application. A RESTful API. |
|
| 124. |
In what way does the closure compiler help in checking the code?(a) Warnings(b) Suddenly aborts(c) Rejects malicious inputs(d) Terminates the execution |
|
Answer» Correct option is (a) Warnings Best explanation: Closure compiler parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. The Closure Compiler provides warnings for illegal JavaScript and warnings for potentially dangerous operations, helping you to produce JavaScript that is less buggy and easier to maintain. |
|
| 125. |
What is a closure compiler UI?(a) Run time application(b) Web application(c) Standalone application(d) Changes structures |
|
Answer» Correct option is (b) Web application Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. A closure compiler UI is a web application. |
|
| 126. |
In how many modes can the Closure compiler be run?(a) 2(b) 3(c) 4(d) 5 |
|
Answer» Right answer is (a) 2 Explanation: Closure Compiler can be run in either of two modes: In Simple mode it mostly performs like most other minifiers, removing whitespace, line breaks, and comments In Advanced mode it rewrites the JavaScript by renaming variables and functions from longer descriptive names to single letters to save file size, and it inlines functions, coalescing them into single functions wherever it determines that it can |
|
| 127. |
What is the task of the Advanced Panel?(a) Test stop running(b) Loading the pages(c) Skewing the results(d) Loading the server |
|
Answer» Right option is (a) Test stop running For explanation: In the Advanced panel, you can have the test stop running at document completion. That will tell us when the document.onload event is fired, instead of when all assets on the page are loaded. |
|
| 128. |
What type of file is YUI Compressor?(a) Binary file(b) JAR file(c) Text file(d) Assembly file |
|
Answer» The correct choice is (b) JAR file Easy explanation: The YUI Compressor is JavaScript minifier designed to be 100% safe and yield a higher compression ratio than most other tools. YUI Compressor is a jar file and runs from the command line. Because of this, it is easily integrated into a build process. It looks like this: java -jar yuicompressor-[version].jar [options] [file name] |
|
| 129. |
Which handler is triggered when the content of the document in the window is stable and ready for manipulation?(a) onload(b) manipulate(c) create(d) onkeypress |
|
Answer» The correct choice is (a) onload The best explanation: One of the most important event handlers is the onload handler of the Window object. It is triggered when the content of the document displayed in the window is stable and ready to be manipulated. JavaScript code is commonly wrapped within an onload event handler. |
|
| 130. |
Which property in the Window object is used to refer to a Location object?(a) position(b) area(c) window(d) location |
|
Answer» Correct answer is (d) location To explain I would say: The Window object defines properties like location, which refers to a Location object that specifies the URL currently displayed in the window and allows a script to load a new URL into the window. The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page. |
|
| 131. |
Which of the following is a web application API framework?(a) Dojo(b) YUI(c) GWT(d) jQuery |
|
Answer» Right answer is (c) GWT For explanation: GWT, the Google Web Toolkit defines a web application API in Java and provides a compiler to translate your Java programs into compatible client-side JavaScript whereas Google Closure Tools is a set of tools to help developers build rich web applications with JavaScript. |
|
| 132. |
Which of the following can be used for a deeper analysis of the web page’s performance?(a) WebPageTest(b) FireBug(c) YSlow(d) WebPageTest & FireBug |
|
Answer» The correct answer is (c) YSlow Explanation: YSlow analyzes web page performance by examining all the components on the page, including components dynamically created by using JavaScript. It measures the page’s performance and offers suggestions for improvement. |
|
| 133. |
Which method is an alternative of the property location of a window object?(a) submit()(b) locate()(c) load()(d) write() |
|
Answer» Right choice is (a) submit() For explanation I would say: HTTP requests are initiated when a script sets the location property of a window object or calls the submit() method of a form object. In both cases, the browser loads a new page. |
|
| 134. |
What is the purpose of the JavaScript Engine?(a) Compiling the JavaScript(b) Interpreting the JavaScript(c) Both Compiling & Interpreting the JavaScript(d) Parsing the javascript |
|
Answer» Correct choice is (b) Interpreting the JavaScript The best I can explain: The JavaScript Engine is generally used for interpreting the JavaScript. It is used to interpret the javascript and execute the javscript on the web page. |
|
| 135. |
What is the purpose of the event handlers in the JavaScript?(a) Adds innerHTML page to the code(b) Performs handling of exceptions and occurrences(c) Allows JavaScript code to alter the behaviour of windows(d) Change the server location |
|
Answer» Right option is (c) Allows JavaScript code to alter the behaviour of windows The explanation: Event handlers allow JavaScript code to alter the behavior of windows, of documents, and of the elements that make up those documents. |
|
| 136. |
Which is the alternative to the load event?(a) readychange(b) changestate(c) readystatechange(d) contentloader |
|
Answer» Right option is (c) readystatechange The explanation is: DOMContentLoaded and readystatechange are alternatives to the load event: they are triggered sooner, when the document and its elements are ready to manipulate, but before external resources are fully loaded. |
|
| 137. |
What is the method to create a data frame?(a) frame(data)(b) frameData()(c) data.frame()(d) frame.Data() |
|
Answer» Correct answer is (c) data.frame() Easy explanation: A Data frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns. |
|
| 138. |
Which identifier is used to represent a web browser window or frame?(a) frames(b) window(c) location(d) frame |
|
Answer» The correct answer is (b) window For explanation I would say: The window object represents a web browser window or frame, and you can refer to it with the identifier window. Global variables are properties of the window object and Global functions are methods of the window object. |
|
| 139. |
What is the purpose of minifying the JavaScript?(a) To streamline the visits(b) To save the visits(c) To save data(d) To increase the loading time |
|
Answer» The correct choice is (a) To streamline the visits Explanation: To ensure that your first-time visits are as streamlined as possible, we need to minify our JavaScript. Minifying JavaScript results in decreasing the loading time and hence helps in creating a better user experience. |
|
| 140. |
What is the purpose of the advanced mode in the closure compiler?(a) Renames variables(b) Renames function(c) Both Renames variables and function(d) Changes structures |
|
Answer» Right option is (c) Both Renames variables and function Easiest explanation: In Advanced mode it rewrites the JavaScript by renaming variables and functions from longer descriptive names to single letters to save file size, and it inlines functions, coalescing them into single functions wherever it determines that it can. |
|
| 141. |
Which is the property of a Window object that holds the name of the frame?(a) name(b) title(c) description(d) style |
|
Answer» The correct choice is (a) name For 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. An iframe creates a nested browsing context represented by a Window object of its own. |
|
| 142. |
What is the purpose of data format validation?(a) Data correctness(b) Mere data existence(c) Both Data correctness and Mere data existence(d) Data modification |
|
Answer» Correct option is (a) Data correctness For explanation: The data entered through the server side is used for validation. The data that is entered must be checked for correct form and value. This would need to put more logic to test the correctness of data. |
|
| 143. |
A JavaScript program can traverse and manipulate document content through __________(a) Element Object(b) Document Object(c) Both Element and Document Object(d) Data object |
|
Answer» Right choice is (c) Both Element and Document Object To explain I would say: A JavaScript program can traverse and manipulate document content through the Document object and the Element objects it contains. It can alter the presentation of that content by scripting CSS styles and classes. The Element object represents an HTML element, like P, DIV, A, TABLE, or any other HTML element. |
|
| 144. |
What is the purpose of the method localeCompare()?(a) If the reference string comes before or after another string(b) If the reference string is validated(c) If the string is a reference string(d) If the reference string comes first |
|
Answer» Correct option is (a) If the reference string comes before or after another string Explanation: The localeCompare() method compares two strings in the current locale. The locale is based on the language settings of the browser. The method localeCompare() returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order. |
|
| 145. |
What will happen if you reference document.location from within an object?(a) Traverses the queue(b) Finds the bugs(c) Traverses the stack(d) Traverses the array |
|
Answer» The correct answer is (c) Traverses the stack For explanation: window.location.href returns the href (URL) of the current page. If you reference document.location from within an object, the interpreter will need to go from the function that references the variable, up out of the namespace to the global window scope, down to the document scope, and gets the location value. |
|
| 146. |
What will be the step of the interpreter in a jump statement when an exception is thrown?(a) The interpreter stops its work(b) The interpreter throws another exception(c) The interpreter jumps to the nearest enclosing exception handler(d) The interpreter throws an error |
|
Answer» Right option is (c) The interpreter jumps to the nearest enclosing exception handler Explanation: When an exception is thrown in a jump statement, the interpreter jumps to the nearest enclosing exception handler, which may be in the same function or up the call stack in an invoking function. |
|
| 147. |
How to lazy load images?(a) Remove the rel attribute(b) Remove the src attribute(c) Make rel = src(d) Make src = rel |
|
Answer» Correct answer is (b) Remove the src attribute Best explanation: The way we would lazy load images would be to alter the HTML of the page to remove the contents of the src attribute of each image. We could just move the contents of the src attribute to an attribute in the image tag of our own design, maybe the rel attribute. |
|
| 148. |
Which of the following is the Web application equivalent to querySelectorAll()?(a) #()(b) &()(c) $()(d) !() |
|
Answer» The correct option is (c) $() Easiest explanation: Web applications based on jQuery use a portable, cross-browser equivalent to querySelectorAll() named $(). |
|
| 149. |
What is the tainted property of the window object?(a) Pathname(b) Protocol(c) Default status(d) Host |
|
Answer» Correct option is (c) Default status To elaborate: The Defaultstatus is the tainted property of the window object. The defaultStatus property sets or returns the default text in the status bar at the bottom of the browser (the text will be displayed when the page loads). |
|
| 150. |
What is the purpose of the timing property in the window.performance object?(a) Time of navigation event(b) Time of page load event(c) Time of navigation and page load event(d) Time of scrolling |
|
Answer» Correct option is (c) Time of navigation and page load event For explanation I would say: Each performance.timing attribute shows the time of a navigation event (such as when the page was requested) or page load event (such as when the DOM began loading), measured in milliseconds. The legacy Performance.timing read-only property returns a PerformanceTiming object containing latency-related performance information. |
|