Javascript MCQ Set 1
1. When are the keyboard events fired?
a) When user manually calls the button
b) When user clicks a key
c) When the user calls the modifier
d) All of the mentioned
Answer
Answer: b [Reason:] The keydown and keyup events are fired when the user presses or releases a key on the keyboard. They are generated for modifier keys, function keys, and alphanumeric keys.
2. How does a user generate multiple keydown events?
a) Repeating the same process
b) Pressing multiple keys
c) Pressing the key longer than usual
d) None of the mentioned
Answer
Answer: c [Reason:] If the user holds the key down long enough for it to begin repeating, there will be multiple keydown events before the keyup event arrives.
3. Which property is used to specify the key type when pressed?
a) keyCode
b) keyType
c) keyName
d) keyProperty
Answer
Answer: a [Reason:] The event object associated with these events has a numeric keyCode property that specifies which key was pressed.
4. What value does the keyCode property holds when a Shift key is pressed for adding punctuation character?
a) Special characters
b) Alphabets
c) Alphanumeric
d) Digits
Answer
Answer: d [Reason:] The number keys always generate keyCode values for the digit that appears on the key, even if you are holding down Shift in order to type a punctuation character.
5. Which of the following are not key event properties?
a) Code key
b) Alt Key
c) Ctrl Key
d) Shift Key
Answer
Answer: a [Reason:] altKey, ctrlKeY, shiftKey, and metaKey are key event object’s properties, which are set to true if the corresponding modifier key is held down when the event occurs.
6. Which of the following key property holds the key name as a string?
a) keyName
b) key
c) keyName(string)
d) Nameofkey(string)
Answer
Answer: b [Reason:] The DOM Level 3 Events defines a new key property that contains the key name as a string.
7. Which of the following is not the value the key property will hold if the key is a function key?
a) F8
b) F2
c) Home
d) Left
Answer
Answer: a [Reason:] If the key is a function key, the key property will be a value like “F2”, “Home”, or “Left”.
8. Which method is used to add a binding?
a) binding()
b) add_bind()
c) bind()
d) None of the mentioned
Answer
Answer: c [Reason:] To add a binding, use bind() method.
9. Which method is used to remove a binding?
a) Unbind()
b) removebind()
c) remove(Bind b)
d) unbind()
Answer
Answer: d [Reason:] To remove a bind, use unbind() method.
10. Which of the following are the parameters passed to the keymap after installation?
a) Key property
b) Key name
c) Keydown event’s object
d) Key stroke
Answer
Answer: c [Reason:] After the keymap is installed, the following parameters are passed:
- The event object for the keydown event.
- The key identifier of the key that was pressed.
Javascript MCQ Set 2
1. What is the purpose of lazy loading?
a) Immediate loading is necessary
b) Loading under command
c) Immediate loading is not necessary
d) None of the mentioned
Answer
Answer: c [Reason:] Lazy loading is a kind of loading in which we don’t need our JavaScript code to be available as soon as the page loads.
2. Where is the external JavaScript placed in the case of lazy loading?
a) After window.onload event
b) Before window.onload event
c) All of the mentioned
d) None of the mentioned
Answer
Answer: a [Reason:] When we don’t need our JavaScript code to be available as soon as the page loads, we can script-load our external JavaScript after the window.onload event.
3. What are the parameters of the attachEvent function?
a) Function
b) Function, Event
c) Event, Function
d) Event
Answer
Answer: c [Reason:] The attachEvent function accepts two parameters: the event to attach to, and the function to invoke when the event occurs.
4. What is the result when the showPerformanceMetrics() is called before loading the remote script?
a) Throws an exception
b) Throws an error
c) It will load by itself
d) None of the mentioned
Answer
Answer: b [Reason:] If you try to make the call to perfLogger.showPerformanceMetrics() and the script hasn’t just loaded but also executed, then you will get an error.
5. Which of the following is an attribute to the script object?
a) onclick
b) onload
c) onshow
d) all of the mentioned
Answer
Answer: b [Reason:] Only onload is an attribute to the script object.
6. Which is the method used to add an event listener?
a) addEventListener()
b) addListener()
c) addEvent(Listener)
d) addListener(Event)
Answer
Answer: a [Reason:] The addEventListener() method is used to add an event listener to the script.
7. What is the purpose of the domLoading attribute?
a) Document exists
b) Document can load
c) Document has loaded
d) Document begins to load
Answer
Answer: d [Reason:] The domLoading attribute is used when the document begins to load.
8. How is the render time calculated?
a) Date.Now()
b) Date.Now() – performance.timing.domLoading
c) performance.domLoading
d) Date.Now() – performance.domLoading
Answer
Answer: b [Reason:] The render time is calculated as Date.Now() – performance.timing.domLoading.
9. The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is
a) Instance object
b) Constructor object
c) Destructor object
d) Prototype object
Answer
Answer: d [Reason:] The properties of the prototype object are inhertied by all instances of the class, and properties whose values are functions behave like instance methods of the class.
10. You can refresh the webpage in JavaScript by using
a) window.reload
b) location.reload
c) window.refresh
d) page.refresh
Answer
Answer: b [Reason:] One can refresh the webpage in JavaScript by using location.reload.
Javascript MCQ Set 3
1. What is the purpose of lazy loading?
a) Immediate loading is necessary
b) Loading under command
c) Immediate loading is not necessary
d) None of the mentioned
Answer
Answer: c [Reason:] Lazy loading is a kind of loading in which we don’t need our JavaScript code to be available as soon as the page loads.
2. Where is the external JavaScript placed in the case of lazy loading?
a) After window.onload event
b) Before window.onload event
c) All of the mentioned
d) None of the mentioned
Answer
Answer: a [Reason:] When we don’t need our JavaScript code to be available as soon as the page loads, we can script-load our external JavaScript after the window.onload event.
3. What are the parameters of the attachEvent function?
a) Function
b) Function, Event
c) Event, Function
d) Event
Answer
Answer: c [Reason:] The attachEvent function accepts two parameters: the event to attach to, and the function to invoke when the event occurs.
4. What is the result when the showPerformanceMetrics() is called before loading the remote script?
a) Throws an exception
b) Throws an error
c) It will load by itself
d) None of the mentioned
Answer
Answer: b [Reason:] If you try to make the call to perfLogger.showPerformanceMetrics() and the script hasn’t just loaded but also executed, then you will get an error.
5. Which of the following is an attribute to the script object?
a) onclick
b) onload
c) onshow
d) all of the mentioned
Answer
Answer: b [Reason:] Only onload is an attribute to the script object.
6. Which is the method used to add an event listener?
a) addEventListener()
b) addListener()
c) addEvent(Listener)
d) addListener(Event)
Answer
Answer: a [Reason:] The addEventListener() method is used to add an event listener to the script.
7. What is the purpose of the domLoading attribute?
a) Document exists
b) Document can load
c) Document has loaded
d) Document begins to load
Answer
Answer: d [Reason:] The domLoading attribute is used when the document begins to load.
8. How is the render time calculated?
a) Date.Now()
b) Date.Now() – performance.timing.domLoading
c) performance.domLoading
d) Date.Now() – performance.domLoading
Answer
Answer: b [Reason:] The render time is calculated as Date.Now() – performance.timing.domLoading.
9. The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is
a) Instance object
b) Constructor object
c) Destructor object
d) Prototype object
Answer
Answer: d [Reason:] The properties of the prototype object are inhertied by all instances of the class, and properties whose values are functions behave like instance methods of the class.
10. You can refresh the webpage in JavaScript by using
a) window.reload
b) location.reload
c) window.refresh
d) page.refresh
Answer
Answer: b [Reason:] One can refresh the webpage in JavaScript by using location.reload.
Javascript MCQ Set 4
1. The development environment offers which standard construct for data validation
a) Super controlled loop constructs
b) Case sensitivity check
c) Validation constructs
d) All of the mentioned
Answer
Answer: d [Reason:] All these facilities are available in JavaScript. Additionally, all development environments provide syntax to create and use memory variables, constants, and functions.
2. The main purpose of a “Live Wire” in NetScape is to
a) Create linkage between client side and server side
b) Permit server side, JavaScript code, to connect to RDBMS
c) Support only non relational database
d) To interpret JavaScript code
Answer
Answer: b [Reason:] A Live Wire database driver also supports a number of non-relational databases.
3. The script tag must be placed in
a) head
b) head and body
c) title and head
d) all of the mentioned
Answer
Answer: b [Reason:] If the script tag is placed after the body tag, then, it will not be evaluated at all. Also, it is always recommended and effective to use the script snippet in the <head> tag.
4. A JavaScript program developed on a Unix Machine
a) will throw errors and exceptions
b) must be restricted to a Unix Machine only
c) will work perfectly well on a Windows Machine
d) will be displayed as a JavaScript text on the browser
Answer
Answer: c [Reason:] None.
5. JavaScript is ideal to
a) make computations in HTML simpler
b) minimize storage requirements on the web server
c) increase the download time for the client
d) none of the mentioned
Answer
Answer: b [Reason:] To minimize storage requirements, JavaScript is always a better say.
6. Which attribute is used to specify that the script is executed when the page has finished parsing ( only for external scripts )
a) parse
b) a sync
c) defer
d) type
Answer
Answer: c [Reason:] In order to load a page, the browser must parse the contents of all script tags, which adds additional time to the page load) By minimizing the amount of JavaScript needed to render the page, and deferring parsing of unneeded JavaScript until it needs to be executed, you can reduce the initial load time of your page.
7. JavaScript Code can be called by using
a) RMI
b) Triggering Event
c) Preprocessor
d) Function/Method
Answer
Answer: d [Reason:] None.
8. JavaScript can be written
a) directly into JS file and included into HTML
b) directly on the server page
c) directly into HTML pages
d) all of the mentioned
Answer
Answer: a [Reason:] None.
9. Which of the following Attribute is used to include External JS code inside your HTML Document
a) src
b) ext
c) script
d) link
Answer
Answer: a [Reason:] A ”src” attribute could be used to add any external code into the HTML document.
10. A proper scripting language is a
a) High level programming language
b) Assembly level programming language
c) Machinen level programming language
d) Low level programming language
Answer
Answer: a [Reason:] None.
Javascript MCQ Set 5
1. The events that are not triggered directly by user activity are called
a) Device-independent input events
b) Device-dependent input events
c) User interface events
d) State change events
Answer
Answer: d [Reason:] Some events are not triggered directly by user activity, but by network or browser activity, and indicate some kind of lifecycle or state-related change. The load event, fired on the Window object when the document is fully loaded, is probably the most commonly used of these events.
2. The video and the audio belong to the
a) Timers and error handlers
b) API-Specific events
c) State change events
d) User interface events
Answer
Answer: b [Reason:] The HTML5 video and audio elements define a long list of associated event types such as “waiting”, “playing”, “seeking”, “volumechange”, and so on. These events are usually only of interest to web apps that want to define custom controls for video or audio playback.
3. The client-side JavaScript’s asynchronous programming model contains
a) Timers and error handlers
b) User interface events
c) State change events
d) API-specific events
Answer
Answer: a [Reason:] Timers and error handlers are part of client-side JavaScript’s asynchronous programming model and are similar to events.
4. Which are the events that have default actions that can be canceled by event handlers?
a) Submit and form-related events
b) Reset and form-related events
c) Submit and reset events
d) None of the mentioned
Answer
Answer: c [Reason:] The submit and reset events have default actions that can be canceled by event handlers, and some click events do, too. The focus and blur events do not bubble, but all the other form events do.
5. The events that represents occurrences related to the browser window are
a) Window
b) Element
c) Display
d) Handlers
Answer
Answer: a [Reason:] Window events represent occurrences related to the browser window itself, rather than any specific document content displayed inside the window.
6. Which event is fired when a document and all of its external resources are fully loaded and displayed to the user?
a) Window
b) Load
c) Element
d) Handler
Answer
Answer: b [Reason:] The load event is the most important of these events: it is fired when a document and all of its external resources (such as images) are fully loaded and displayed to the user.
7. Which is the alternative to the load event?
a) readychange
b) changestate
c) readystatechange
d) contentloader
Answer
Answer: c [Reason:] 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.
8. Which is the opposite to the load event in JavaScript?
a) dontload
b) postload
c) preload
d) unload
Answer
Answer: d [Reason:] The unload event is the opposite of load: it is triggered when the user is navigating away from a document. An unload event handler might be used to save the user’s state, but it cannot be used to cancel navigation.
9. Which is the property that is triggered in response to JavaScript errors?
a) onexception
b) onmessage
c) onerror
d) none of the mentioned
Answer
Answer: c [Reason:] The onerror property of the Window object is something like an event handler, and it is triggered in response to JavaScript errors. It isn’t a true event handler, however, because it is invoked with different arguments.
10. Which event can be fired on any scrollable document element?
a) Window
b) Scroll
c) Load
d) Unload
Answer
Answer: b [Reason:] Scroll events can also be fired on any scrollable document element, such as those with the CSS overflow property set.
Synopsis and Project Report
You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com