1. Where are memory leaks found?
a) Client side objects
b) Server side objects
c) Both Client side and Server side objects
d) User side objects
Explanation: Memory leaks happen when your code needs to consume memory in your application, which should be released after a given task is completed but isn’t. Memory leaks occur when we are developing client-side reusable scripting objects.
2. Which handler is triggered when the content of the document in the window is stable and ready for manipulation?
- A distinguished set of objects are assumed to be reachable: these are known as the roots. Typically, these include all the objects referenced from anywhere in the call stack (that is, all local variables and parameters in the functions currently being invoked), and any global variables.
- Objects are kept in memory while they are accessible from roots through a reference or a chain of references.
4. When does a memory leak happen?
a) Browser doesn’t release memory from objects unnecessary
b) Browser releases too many memories
c) Browser releases memory iteratively
d) Browser releases memory quickly
Explanation: Memory leaks happen when your code needs to consume memory in your application, which should be released after a given task is complete but isn’t. Memory leak happens when the browser for some reason doesn’t release memory from objects which are not needed any more.
5. What will happen when the data of the jQuery.cache is read from an element?
a) Unique number is retrieved as elem[jQuery.expando]
b) Data is read from jQuery.cache[id]
c) Unique number is retrieved as elem[jQuery.expando] & Data is read from jQuery.cache[id]
d) Data is cleared from jQuery.cache[id]
Explanation: jQuery.cache[id] is used to associate handlers and other data with elements. When the data is read from an element:
- The element unique number is retrieved from id = elem[ jQuery.expando].
- The data is read from jQuery.cache[id].
6. The style property belongs to which of the following object?
Explanation: Each Element object has style and className properties that allow scripts to specify CSS styles for a document element or to alter the CSS class names that apply to the element.
7. Which of the following functions are referenced internally?
c) both setTimeout and setInterval
Explanation: setTimeout(function, milliseconds) executes a function, after waiting a specified number of milliseconds. Functions used in setTimeout/setInterval are referenced internally and tracked until complete, then cleaned up.
8. What is the purpose of destroying the functions and objects?
a) Consume unnecessary CPU cycles
b) Prevent the dropping of reference count to 0
c) Centralize the responsibility to clean up
d) All of the mentioned
Explanation: The primary purpose of a destroy function is to centralize the responsibility for cleaning up anything that the object has done that will:
- Prevent its reference count from dropping to 0 (for example, removing problematic event listeners and callbacks and unregistering from any services).
- Consume unnecessary CPU cycles, such as intervals or animations.
9. When does a cycle occur during memory leak?
a) No reference occurs
b) Two objects reference
c) One object gets referenced
d) Three object gets referenced
10. Which of the following is a way to retain an object in memory?
a) Console Log
c) Destroy objects
d) Clear object
Explanation: Any object inside the timer will hold a reference in order to run that piece of code somewhere in the future without any problems. One particularly obscure way to retain an object in memory is to log it to the console.
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Programming Books
- Practice Programming MCQs
- Practice Information Science MCQs
- Practice MCA MCQs