Javascript MCQ Set 1
1. The URL property belongs to which of the following object?
a) Document
b) Element
c) Location
d) All of the mentioned
Answer
Answer: a [Reason:] The Document object has a URL property, which is a static string that holds the URL of the document when it was first loaded.
2. What does the location property represent?
a) Current DOM object
b) Current URL
c) Both DOM object and URL
d) None of the mentioned
Answer
Answer: a [Reason:] The location property of a window is a reference to a Location object; it represents the current URL of the document being displayed in that window.
3. Which among the following is not a property of the Location object?
a) protocol
b) host
c) hostee
d) hostname
Answer
Answer: c [Reason:] The various properties of the location object are the protocol, host, hostname, port, search, and hash.
4. What is the return type of the hash property?
a) Query string
b) Packets
c) String
d) Fragment identifier
Answer
Answer: d [Reason:] The hash property returns the “fragment identifier” portion of the URL, if there is one: a hash mark (#) followed by an element ID.
5. What is the function used to extract arguments from the search property of a URL?
a) urlArgs()
b) url()
c) hash()
d) none of the mentioned
Answer
Answer: a [Reason:] The urgArgs() function can be used to extract arguments from the search property of a URL.
6. The decodeURIComponent() is defined by
a) Server-side JavaScript
b) Client-side JavaScript
c) Both Server-side and Client-side JavaScript
d) None of the mentioned
Answer
Answer: b [Reason:] The decodeURIComponent() is a global function defined by client-side JavaScript.
7. Which is the method that removes the current document from the browsing history before laoding the new document?
a) modify()
b) assign()
c) replace()
d) remove()
Answer
Answer: c [Reason:] 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().
8. Why is the replace() method better than the assign() method?
a) Reliable
b) Highly managable
c) More efficient
d) Handles unconditional loading
Answer
Answer: d [Reason:] 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().
9. What is the purpose of the assign() method?
a) Only loading
b) Loading of window and display
c) Displays already present window
d) Unloading of window
Answer
Answer: b [Reason:] The assign() method of the Location object makes the window load and display the document at the URL you specify.
10.The history property belongs to which object?
a) Element
b) Window
c) History
d) Location
Answer
Answer: c [Reason:] The history property of the Window object refers to the History object for the window.
Javascript MCQ Set 2
1. How many properties does a prototype object have?
a) 6
b) 7
c) 8
d) 9
Answer
Answer: b [Reason:] There are a total of 7 properties in the prototype object namely :
- perceivedTime
- redirectTime
- cacheTime
- dnsLookupTime
- tcpConnectionTime
- roundTripTime
- pageRenderTime.
2. Which of the following does not serialize the undefined values or objects within an object?
a) JSON.string
b) JSON
c) JSON.stringify
d) None of the mentioned
Answer
Answer: c [Reason:] JSON.stringify does not serialize undefined values or functions within an object.
3. How many properties are there in the interface PerformanceTiming?
a) 21
b) 22
c) 23
d) 24
Answer
Answer: a [Reason:] There are a total of 23 properties associated with the interface PerformanceTiming.
4. How many properties are there in window.performance object?
a) 1
b) 4
c) 2
d) 3
Answer
Answer: c [Reason:] There are totally 2 properties associated with the window.performance and they are:
- navigation
- type.
5. What is the purpose of the navigation property in the window.performance object?
a) To which page the user navigated
b) How the user navigated
c) All of the mentioned
d) None of the mentioned
Answer
Answer: b [Reason:] The navigation tells how the user navigated to the page.
6. What is the purpose of the property PerformanceTiming.navigationStart?
a) Ready to end the navigation
b) Ready to jump the navigation
c) Ready for navigation
d) None of the mentioned
Answer
Answer: c [Reason:] The PerformanceTiming.navigationStart read-only property returns an unsigned long long representing the moment, in miliseconds since the UNIX epoch, right after the prompt for unload terminates on the previous document in the same browsing context. If there is no previous document, this value will be the same as : PerformanceTiming.fetchStart.
7. Which of the following does JSON.stringify not serialize?
a) Undefined values
b) Functions within an object
c) Both Undefined values and Functions within an object
d) None of the mentioned
Answer
Answer: c [Reason:] JSON.stringify does not serialize undefined values or functions within an object.
8. What is the purpose of the property PerformanceTiming.fetchStart?
a) Browser ready to fetch input
b) Browser ready to fetch document
c) Browser ready to fetch summary
d) All of the mentioned
Answer
Answer: b [Reason:] The PerformanceTiming.fetchStart read-only property returns an unsigned long long representing the moment, in miliseconds since the UNIX epoch, the browser is ready to fetch the document using an HTTP request.
9. Which of the following property is associated with the Request event?
a) requestStart
b) requestEnd
c) both requestStart and requestEnd
d) none of the mentioned
Answer
Answer: a [Reason:] The Request event has only one property : requestStart.
10. Which of the following API can be used to get the timing without affecting the page loading process?
a) Navigation API
b) Timing API
c) Navigation Timing API
d) None of the mentioned
Answer
Answer: c [Reason:] The timing code is in the page, so it affects how the page loads and the time that takes.. The Navigation Timing API can be used to get the timing without affecting the page loading process.
Javascript MCQ Set 3
1. What is the inital step to set up a CSS Lazy Loading?
a) Fetching data
b) Loading the script
c) Loading the page
d) Adding the event listener
Answer
Answer: a [Reason:] The CSS Lazy Loading is begun with fetching the JavaScript and the CSS files.
2. Consider the following code snippet :
<script> if (window.attachEvent) window.attachEvent('onload', fetch); else window.addEventListener('load', fetch, false); </script>
What is being done in the above code in JavaScript?
a) Event and EventListener is created according to the if-else
b) The values are updated
c) All of the mentioned
d) None of the mentioned
Answer
Answer: a [Reason:] In the above code, the event is attached with onload and the fetch function is called) Also, the event listener is created and added if the “if” fails and is stored as load and the fetch function is called.
3. What is the purpose of holding whatever tag you create in the attribute type?
a) To have more information
b) To identify the scripting language
c) All of the mentioned
d) None of the mentioned
Answer
Answer: b [Reason:] A variable is created to hold whatever taag you create, and then branch the logic based on the value of type, which identifies it’s for JavaScript or for CSS.
4. What does the appendChild() method perform?
a) Appends a node in the middle of the index taken as the parameter
b) Appends a node as the first child
c) Appends a node as the last child
d) None of the mentioned
Answer
Answer: c [Reason:] The appendChild() method appends a node as the last child of a node.
5. Consider the following code snippet :
<script> function fetch(){ remoteLoader.loadJS("/lab/perfLogger.js", init) remoteLoader.loadCSS(["/style/base.css", "http://fonts.googleapis.com/css?family=Metrophobi c&v2"]) } </script>
What is being done in the above function in JavaScript?
a) JS and CSS files are deleted
b) CSS is replaced with JS
c) JS is replaced with CSS
d) JS and CSS files are loaded
Answer
Answer: d [Reason:] In the above function, the JavaScript and the CSS files are loaded remotely.
6. What should be the value of the type attribute of a variable if the type of file is CSS?
a) text/js/css
b) text/js
c) text/css
d) text
Answer
Answer: c [Reason:] Since the type of file is CSS, the type attribute should hold the value text/css.
7. How to lazy load images?
a) Remove the rel attribute
b) Remove the src attribute
c) Make rel = src
d) Make src = rel
Answer
Answer: b [Reason:] 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.
<img src="#" rel="[path to image]" />
8. What does the rel attribute of a variable have when the type of file is CSS?
a) css
b) stylesheet
c) text/css
d) all of the mentioned
Answer
Answer: b [Reason:] The rel attribute must hold the value rel = ‘stylesheet’.
9. What is the parameter of the method getElementsbyTagName() if we need to get an image?
a) image
b) src
c) img
d) imageurl
Answer
Answer: c [Reason:] The method must look like getElementsbyTageName(“img”) if we need to get an image.
10. How do we stop blocking of loading and executing the perfLogger, a logging type data?
a) Inlining the perfLogger
b) Removing the perfLogger
c) Placing the perfLogger before the “script” tag
d) None of the mentioned
Answer
Answer: a [Reason:] By inlining the perfLogger, we no longer block the loading and executing of it.
Javascript MCQ Set 4
1. What are the features of an interpreter?
a) Shared with other properties
b) Embedded in other tools
c) Shared with other properties & Embedded in other tools
d) None of the mentioned
Answer
Answer: c [Reason:] The interpreter can be shared with other properties, or embedded in other tools.
2. Why is the total size of the page important?
a) Time taken to download
b) Size of IP packet should be less than 65500
c) Size of IP packet should be less than 65535
d) Size of IP packet should be greater than 65500
Answer
Answer: c [Reason:] The total size of the page is important, not just because of the time it takes to download, but because the maximum size of an IP packet is 65535 octets for IPv4 and IPv6.
3. How will the HTTP GET request be sent from the browser?
a) Remote server
b) Local server
c) By itself
d) None of the mentioned
Answer
Answer: a [Reason:] Once the TCP/IP connection has been established, the browser sends an HTTP GET request over the connection to the remote server. The remote server finds the resource and returns it in an HTTP Response, the status of which is 200 to indicate a good response.
4. What is the return type of the remote server?
a) HTTP Response
b) HTTP Request
c) Get Request
d) None of the mentioned
Answer
Answer: a [Reason:] The remote server finds the resource and returns it in an HTTP Response, the status of which is 200 to indicate a good response.
5. Which layer is used to control the communication between the hardware in the network?
a) Network Access Layer
b) Internet Layer
c) Transport Layer
d) Presentation Layer
Answer
Answer: a [Reason:] The Network Access layer controls the communication between the hardware in the network.
6. Which layer is used to handle the network addressing and routing?
a) Network Access Layer
b) Internet Layer
c) Transport Layer
d) Presentation Layer
Answer
Answer: b [Reason:] The Internet layer handles network addressing and routing, getting IP and MAC addresses.
7. The layer in which the TCP (or UDP) communication takes place is
a) Network Access Layer
b) Internet Layer
c) Transport Layer
d) Presentation Layer
Answer
Answer: c [Reason:] The Transport layer is where our TCP (or UDP) communication takes place.
8. Which layer handles the top-level communication?
a) Network Access Layer
b) Internet Layer
c) Transport Layer
d) Application Layer
Answer
Answer: d [Reason:] The Application layer handles the top-level communication that the client and servers use, like HTTP and SMTP for email clients.
9. What are the various possessions in the three-way handshake by the TCP?
a) Synchronize
b) Synchronize-Acknowledge
c) Acknowledge message
d) All of the mentioned
Answer
Answer: d [Reason:] This handshake consists of a Synchronize, Synchronize-Acknowledge, and Acknowledge message to be passed between the browser and the remote server. This handshake allows the client to attempt communication, the server to acknowledge and accept the attempt, and the client to acknowledge that the attempt has been accepted.
10. Arrange the TCP/IP model layers in the order from furthest to closest to the end user.
a) Network Access Layer, Internet Layer, Application Layer, Transport Layer
b) Network Access Layer, Transport Layer, Internet Layer, Application Layer
c) Network Access Layer, Internet Layer, Transport Layer, Application Layer
d) Network Access Layer, Application Layer, Internet Layer, Transport Layer
Answer
Answer: c [Reason:] The four layers in the TCP/IP model are, in order from furthest to closest to the end user, the Network Access layer, the Internet layer, the Transport layer, and the Application layer.
Javascript MCQ Set 5
1. Each tab in the single web browser window is called as
a) Browser Information
b) Browsing context
c) Both Browser Information & Browsing context
d) None of the mentioned
Answer
Answer: b [Reason:] A single web browser window on your desktop may contain several tabs. Each tab is an independent browsing context.
2. Nested documents in the HTML can be done using
a) frame
b) nest
c) iframe
d) into
Answer
Answer: c [Reason:] HTML documents may contain nested documents using an iframe element. An iframe creates a nested browsing context represented by a Window object of its own.
3. What is the distinction made by the Client-side JavaScript between windows, tabs, iframes, and frames ?
a) They are all browsing contexts
b) They are all browsing informations
c) They are all Window contexts
d) They are all Window objects
Answer
Answer: a [Reason:] Client-side JavaScript makes very little distinction between windows, tabs, iframes, and frames: they are all browsing contexts, and to JavaScript, they are all Window objects.
4. What is the distinction made by JavaScript between windows, tabs, iframes, and frames ?
a) They are all browsing contexts
b) They are all browsing informations
c) They are all Window contexts
d) They are all Window objects
Answer
Answer: d [Reason:] Client-side JavaScript makes very little distinction between windows, tabs, iframes, and frames: they are all browsing contexts, and to JavaScript, they are all Window objects.
5. A new web browser window can be opened using which method of the Window object ?
a) createtab()
b) Window.open()
c) open()
d) all of the mentioned
Answer
Answer: b [Reason:] You can open a new web browser window with the open() method of the Window object. Window.open() loads a specified URL into a new or existing window and returns the Window object that represents that window.
6. What will happen if the first argument of open() is omitted?
a) Error Page
b) Remains in the same page
c) about:blank
d) None of the mentioned
Answer
Answer: b [Reason:] When the first argument of the open() is omitted, the about:blank is opened.
7. Which object serves as the global object at the top of the scope chain?
a) Hash
b) Property
c) Element
d) Window
Answer
Answer: d [Reason:] The Window object serves as the global object at the top of the scope chain in client-side JavaScript.
8. Which is the property of a Window object that holids the name of the frame?
a) name
b) title
c) description
d) none of the mentioned
Answer
Answer: a [Reason:] 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.
9. When will the fourth argument to open() useful?
a) When the second argument names a retired window
b) When the first argument names an existing window
c) When the second argument names an existing window
d) When the first argument names a retired window
Answer
Answer: c [Reason:] The fourth argument to open() is useful only when the second argument names an existing window. This fourth argument is a boolean value that indicates whether the URL specified as the first argument should replace the current entry in the window’s browsing history (true) or create a new entry in the window’s browsing history (false). Omitting this argument is the same as passing false.
10. The inner frame within a top-level window can be referred as
a) parent(parent)
b) parent.parent
c) parent*parent
d) none of the mentioned
Answer
Answer: b [Reason:] If a frame is contained within another frame that is contained within a top-level window, that frame can refer to the top-level window as parent.parent.
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