Javascript MCQ Set 1
1. JavaScript Code can be called by using
a) RMI
b) Triggering Event
c) Preprocessor
d) Function/Method
Answer
Answer: d [Reason:] JavaScript code is as easy to be implemented and run. It can be called by using a function or a method)
2. The type of a variable that is volatile is
a) Volatile variable
b) Mutable variable
c) Immutable variable
d) Dynamic variable
Answer
Answer: b [Reason:] The variables whose values can be changed are called mutable variable types.
3. A hexadecimal literal begins with
a) 00
b) 0x
c) 0X
d) Both 0x and 0X
Answer
Answer: d [Reason:] Generally, X or x denotes hexadecimal values. So, any integer literal that begins with 0X or 0x denotes a hexadecimal number.
4. The generalised syntax for a real number representation is
a) [digits][.digits][(E|e)[(+|-)]digits].
b) [digits][+digits][(E|e)[(+|-)]digits].
c) [digits][(E|e)[(+|-)]digits].
d) [.digits][digits][(E|e)[(+|-)]digits].
Answer
Answer: a [Reason:] Floating-point literals may also be represented using exponential notation: a real number followed by the letter e (or E), followed by an optional plus or minus sign, followed by an integer exponent. This notation represents the real number multiplied by 10 to the power of the exponent.
5. When there is an indefinite or an infinity value during an arithmetic value computation, javascript
a) Prints an exception error
b) Prints an overflow error
c) Displays “Infinity”
d) Prints the value as such
Answer
Answer: c [Reason:] When the result of a numeric operation is larger than the largest representable number (overflow), the result is a special infinity value, which JavaScript prints as Infinity. Similarly, when a negative value becomes larger than the largest representable negative number, the result is negative infinity, printed as -Infinity. The infinite values behave as you would expect: adding, subtracting, multiplying, or dividing them by anything results in an infinite value (possibly with the sign reversed.
6. Which of the following is not considered as an error in JavaScript?
a) Syntax error
b) Missing of semicolons
c) Division by zero
d) All of the mentioned
Answer
Answer: c [Reason:] Division by zero is not an error in JavaScript: it simply returns infinity or negative infinity. There is one exception, however: zero divided by zero does not have a welldefined value, and the result of this operation is the special not-a-number value, printed as NaN.
7. The escape sequence ‘f’ stands for
a) Floating numbers
b) Representation of functions that returns a value
c) f is not present in JavaScript
d) Form feed
Answer
Answer: d [Reason:] f is the JavaScript escape sequence that stands for Form feed (u000C).
8. 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
Answer: d [Reason:] The not-equal operator !== compares o to null and evaluates to either true or false.
9. The statement a===b refers to
a) Both a and b are equal in value, type and reference address
b) Both a and b are equal in value
c) Both a and b are equal in value and type
d) There is no such statement
Answer
Answer: c [Reason:] a==b returns a true if a and b refer to the same objec ,so they are equal, else it returns a false.
10. Assume that we have to convert “false” that is a non-string to string. The command that we use is (without invoking the “new” operator)
a) false.toString()
b) String(false)
c) String newvariable=”false”
d) Both false.toString() and String(false)
Answer
Answer: d [Reason:] A non-string can be converted in two ways without using a new operator. false.toString() and String(false).
Javascript MCQ Set 2
1. In which part does the form validation occur?
a) Client
b) Server
c) Both Client and Server
d) None of the mentioned
Answer
Answer: b [Reason:] Form validation used to occur at the server, after the client had entered all necessary data and then pressed the Submit button.
2. What would happen if the data in the client had been wrong?
a) Sends back the data
b) Waits for correction
c) Sends back the data and Waits for correction
d) None of the mentioned
Answer
Answer: c [Reason:] If some of the data that had been entered by the client had been in the wrong form or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information.
3. What is the purpose of the basic validation?
a) Data correctness
b) Mere data existence
c) Both Data correctness and Mere data existence
d) None of the mentioned
Answer
Answer: b [Reason:] First of all, the form must be checked to make sure data was entered into each form field that required it. This would need just loop through each field in the form and check for data.
4. What is the purpose of data format validation?
a) Data correctness
b) Mere data existence
c) Both Data correctness and Mere data existence
d) None of the mentioned
Answer
Answer: a [Reason:] The data that is entered must be checked for correct form and value. This would need to put more logic to test correctness of data.
5. Which is the function that is called to validate a data?
a) validate()
b) valid()
c) validation()
d) none of the mentioned
Answer
Answer: d [Reason:] There is no such function to validate a data) But, you can write a function with any name to validate the data.
6. How to find the index of a particular string?
a) position()
b) index()
c) indexOf()
d) none of the mentioned
Answer
Answer: c [Reason:] The indexOf() function can be used to find out the index of a particular character or a string.
7. How do you focus a particular part of the HTML page in JavaScript?
a) hover()
b) focus()
c) on()
d) all of the mentioned
Answer
Answer: b [Reason:] The focus() function can be used to focus a particular part of the HTML page in JavaScript.
8. Which of the following is the child object of the JavaScript navigator?
a) Navicat
b) Plugins
c) NetRight
d) None of the mentioned
Answer
Answer: b [Reason:] The JavaScript navigator object includes a child object called plugins.
9. Which of the following are the properties of a plug-in entry?
a) name
b) filename
c) mimeTypes
d) all of the mentioned
Answer
Answer: d [Reason:] Each plug-in has an entry in the array. Each entry has the following properties:
- name – is the name of the plug-in.
- filename – is the executable file that was loaded to install the plug-in.
- description – is a description of the plug-in, supplied by the developer.
- mimeTypes – is an array with one entry for each MIME type supported by the plug-in.
10. What is the purpose of the mimeTypes property of a plug-in entry?
a) Contains MIME properties
b) Contains MIME sizes
c) Contains MIME types
d) None of the mentioned
Answer
Answer: c [Reason:] mimeTypes is an array with one entry for each MIME type supported by the plug-in.
Javascript MCQ Set 3
1. Which of the following is a stateless protocol?
a) HTML
b) XHTML
c) HTTP
d) All of the mentioned
Answer
Answer: c [Reason:] HTTP is a stateless protocol. A stateless protocol does not require the server to retain information or status about each user for the duration of multiple requests.
2. What does the value 2 of the WebSocket attribute Socket.readyState indicate?
a) Closed connection
b) Handshake connection
c) Unestablished connection
d) Established connection and communication is possible
Answer
Answer: b [Reason:] The readonly attribute readyState represents the state of the connection. It can have the following values:
- A value of 0 indicates that the connection has not yet been established.
- A value of 1 indicates that the connection is established and communication is possible.
- A value of 2 indicates that the connection is going through the closing handshake.
- A value of 3 indicates that the connection has been closed or could not be opened.
3. How many WebSocket events are available?
a) 2
b) 3
c) 4
d) 5
Answer
Answer: c [Reason:] There are fourWebSocket events namely :
- open
- close
- message
- error
4. Which method is used to close the WebSocket?
a) Socket.flush()
b) Socket.close()
c) Socket.Close()
d) Socket.dispose()
Answer
Answer: b [Reason:] The Socket.close() is used to close the WebSocket.
5. How does the client and the server communicate following the rules defined by the WebSocket protocol?
a) Long-lived TCP Socket
b) Short-lived TCP Socket
c) UDP Socket
d) HTTP Socket
Answer
Answer: a [Reason:] The client and server communicate over a long-lived TCP socket following rules defined by the WebSocket protocol.
6. Which of the following are not a socket property?
a) onopen
b) readyState
c) onmessage
d) ready
Answer
Answer: d [Reason:] There is no Socket property called ready.
7. Consider the following one-line code
var httpserver = new http.Server();
What does the above code do?
a) Create an HTTP Server
b) Create HTTP Connection between Client and Server
c) HTTP Server & Connection
d) None of the mentioned
Answer
Answer: a [Reason:] The above code creates an HTTP Server.
8. How can we check the subprotocol being used by the client?
a) subprotocol property
b) protocol property
c) clientprotocol property
d) none of the mentioned
Answer
Answer: b [Reason:] Once the connection is established, the client can determine which subprotocol is in use by checking the protocol property of the socket.
9. How will you transmit data using the connection?
a) send(data)
b) Socket.send(“data”)
c) Socket.send(data)
d) Socket(data)
Answer
Answer: c [Reason:] The Socket.send(data) method transmits data using the connection.
10. Which of the following is not a WebSocket event?
a) open
b) close
c) error
d) deny
Answer
Answer: d [Reason:] There is no WebSocket event named deny. The four WebSocket events are
- open
- close
- message
- error
Javascript MCQ Set 4
1. Which of the following is one of the fundamental features of JavaScript?
a) Single-threaded
b) Multi-threaded
c) Both Single-threaded and Multi-threaded
d) None of the mentioned
Answer
Answer: a [Reason:] One of the fundamental features of client-side JavaScript is that it is single-threaded: a browser will never run two event handlers at the same time, and it will never trigger a timer while an event handler is running, for example.
2. Which of the following functions are synchronous?
a) load()
b) require()
c) both load() and require()
d) none of the mentioned
Answer
Answer: c [Reason:] JavaScript has two synchronous load() and require().
3. Why shouldn’t JavaScript functions not be too long?
a) User friendliness
b) Tie up event loops
c) Browser becomes unresponsive
d) All of the mentioned
Answer
Answer: d [Reason:] The client-side JavaScript functions must not run too long: otherwise they will tie up the event loop and the web browser will become unresponsive to user input.
4. The object that looks to the thread that creates it is
a) Window
b) Worker
c) Element
d) Hash
Answer
Answer: b [Reason:] The Worker object: this is what a worker looks like from the outside, to the thread that creates it.
5. Which of the following is a global object for a new worker?
a) WorkerGlobalScope
b) Worker
c) WorkerScope
d) Window
Answer
Answer: a [Reason:] The WorkerGlobalScope is the global object for a new worker, and it is what a worker thread looks like, on the inside, to itself.
6. Which will be invoked to create a new worker?
a) Function
b) Destructor
c) Constructor
d) Interface
Answer
Answer: c [Reason:] To create a new worker, just use the Worker() constructor, passing a URL that specifies the JavaScript code that the worker is to run :
var loader = new Worker("utils/loader.js");
7. What will happen if you specify an absolute URL in the Worker constructor?
a) Resolves itself
b) Must have the same origin
c) Must not have the same origin
d) None of the mentioned
Answer
Answer: b [Reason:] If you specify an absolute URL, it must have the same origin (same protocol, host, and port) as that containing document.
8. How can you send data using a Worker object?
a) postMessage()
b) sendMessage()
c) Message()
d) post()
Answer
Answer: a [Reason:] 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:
loader.postMessage("file.txt");
9. Which property is used to manage multiple event handlers?
a) onmessage
b) onerror
c) both onmessage and onerror
d) none of the mentioned
Answer
Answer: c [Reason:] You can use onmessage and onerror properties if you want to manage multiple event handlers.
10. Which is the function that allows a worker to terminate itself?
a) close()
b) exit()
c) terminate()
d) halt()
Answer
Answer: a [Reason:] The close() function allows a worker to terminate itself, and it is similar in effect to the terminate() method of a Worker object.
Javascript MCQ Set 5
1. How many parameters does the WebPageTest API accept?
a) 5
b) 6
c) 7
d) 8
Answer
Answer: d [Reason:] The WebPageTest API accepts totally 8 parameters, namely url, location, runs, fvonly, private, block, f, k.
2. What is the purpose of getting the parameter block?
a) Permission to block
b) Space separated block list
c) Comma separated block list
d) All of the mentioned
Answer
Answer: c [Reason:] This parameter allows you to set a comma separated list of block options.
3. What will happen if you set the private flag as 1?
a) Test will be run only by the administrator
b) Test will not be run
c) Test is public
d) Test is not displayed in public
Answer
Answer: d [Reason:] Setting the private flag to 1 will make sure that the test is not displayed in the public list of tests.
4. What is the purpose of getting the paramerer fvonly?
a) To repeat the view test
b) To get the first view
c) To debug the code
d) None of the mentioned
Answer
Answer: b [Reason:] If you set fvonly to 1, you get results only for the first view, and do not run the repeat view test.
5. What is the purpose of the file_get_contents()?
a) To get the errors and exceptions
b) To get the client’s response
c) To get the server’s response
d) None of the mentioned
Answer
Answer: c [Reason:] The file_get_contents() is a PHP’s native function used to hit the URL and read the server’s response into
a variable $wpt_response:
$wpt_response = file_get_contents($wpt_url . $urls_to_benchmark[$x]);
6. What will the file_get_contents() return?
a) Server’s response
b) Errors
c) Exception
d) Client’s response
Answer
Answer: a [Reason:] The file_get_contents() is a PHP’s native function used to hit the URL and read the server’s response into
a variable $wpt_response:
$wpt_response = file_get_contents($wpt_url . $urls_to_benchmark[$x]);
7. How will you convert the returned API into an XML object?
a) SimpleElement()
b) SimpleXMLElement()
c) XMLElement()
d) None of the mentioned
Answer
Answer: b [Reason:] The API returned by the method file_get_contents() can be converted into an XML object using the method SimpleXMLElement().
8. Which tag can handle mouse events in Netscape?
a) img
b) a
c) br
d) none of the mentioned
Answer
Answer: a [Reason:] The img element can handle mouse events in Netscape.
9. What is the tainted property of the window object?
a) Pathname
b) Protocol
c) Default status
d) Host
Answer
Answer: c [Reason:] The Defaultstatus is the tainted property of the window object.
10. Which environment variable must the user enable in order to enable data tainting?
a) ENABLE_TAINT
b) MS_ENABLE_TAINT
c) NS_ENABLE_TAINT
d) ENABLE_TAINT_NS
Answer
Answer: c [Reason:] The environment variable NS_ENABLE_TAINT must be enabled in order to enable data tainting.
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