Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Javascript MCQ Set 1

1. The unordered collection of properties, each of which has a name and a value is called
a) String
b) Object
c) Serialized Object
d) All of the mentioned

View Answer

Answer: b [Reason:] An object is an unordered collection of properties, each of which has a name and a value. Property names are strings, so we can say that objects map strings to values.

2. The object has three object attributes namely
a) Class, parameters, object’s extensible flag
b) Prototype, class, objects’ parameters
c) Prototype, class, object’s extensible flag
d) Native object, Classes and Interfacces and Object’s extensible flag

View Answer

Answer: c [Reason:] Every object has three associated object attributes :

  1. An object’s prototype is a reference to another object from which properties are inherited.
  2. An object’s class is a string that caegorizes the type of an object.
  3. An object’s extensible flag specifies whether new properties may be added to the object.

3. Consider the following code snippet :

var book = {
              "main title": "JavaScript", 
              'sub-title': "The Definitive Guide", 
              "for": "all audiences", 
              author: { 
                         firstname: "David", 
                         surname: "Flanagan" 
                      }
           };

In the above snippet, firstname and surname are
a) properties
b) property values
c) property names
d) objects

View Answer

Answer: c [Reason:] firstname and surname are the property names. The value of that particular property is itself an object. That is why these property names are unquoted.

4. A linkage of series of prototype objects is called as :
a) prototype stack
b) prototype chain
c) prototype class
d) prototypes

View Answer

Answer: b [Reason:] Consider an example, Date.prototype inherits properties from Object.prototype, so a Date object created by new Date() inherits properties from both Date.prototype and Object.prototype. This linked series of prototype objects is known as prototype chain.

5. Consider the below given syntax

book[datatype]=assignment_value;

In the above syntax, the datatype within the square brackets must be
a) An integer
b) A String
c) An object
d) None of the mentioned

View Answer

Answer: b [Reason:] When using square bracket notation, the expression inside the square brackets must evaluate to a sting or a value that can be converted to a string.

6. To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the
a) isPrototypeOf() method
b) equals() method
c) === operator
d) none of the mentioned

View Answer

Answer: a [Reason:] To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the isPrototype() method. To find out if p is the prototype of o write p.isPrototypeOf(o).

7. Consider the following code snippet

function f() {};

The above prototype represents a
a) Function f
b) A custom constructor
c) Prototype of a function
d) Not valid

View Answer

Answer: b [Reason:] The above code snippet defines a custom constructor.

8. The purpose of extensible attribute is to
a) make all of the own properties of that object nonconfigurable
b) to configure and bring a writable property
c) “lock down” objects into a known state and prevent outside tampering
d) all of the mentioned

View Answer

Answer: c [Reason:] The purpose of the extensible attribute is to be able to “lock down” objects into a known state and prevent outside tampering.

9. Identify the process done in the below code snippet

o = {x:1, y:{z:[false,null,""]}}; 
s = JSON.stringify(o); 
p = JSON.parse(s);

a) Object Encapsulation
b) Object Serialization
c) Object Abstraction
d) Object Encoding

View Answer

Answer: b [Reason:] Object serialization is the process of converting an object’s state to a string from which it can later be restored.

10. The basic purpose of the toLocaleString() is to
a) return a localised object representation
b) return a parsed string
c) return a local time in the string format
d) return a localized string representation of the object

View Answer

Answer: d [Reason:] None.

Javascript MCQ Set 2

1. When does the browser stop rendering the HTML?
a) Inline JavaScript block
b) External JavaScript file
c) Both Inline JavaScript block & External JavaScript file
d) None of the mentioned

View Answer

Answer: c [Reason:] When the browser parses the HTML markup, it stops rendering the HTML when it encounters an inline JavaScript block or external JavaScript file. At this point, the user experiences rendering delays. Moving the JavaScript to the end of the HTML markup would completely eliminate these pauses in rendering.

2. Which of the following handles painting the content on to the screen?
a) Rendering engine
b) JavaScript Interpreter
c) UI Layer
d) Network Layer

View Answer

Answer: a [Reason:] The rendering engine handles painting the content to the screen. When it encounters JavaScript, it hands it off to the JavaScript interpreter.

3. What does the rendering engine do when it encounters JavaScript?
a) Skips the code
b) Continues painting
c) Switches to Javascript Interpreter
d) None of the mentioned

View Answer

Answer: c [Reason:] The rendering engine handles painting the content to the screen. When it encounters JavaScript, it hands it off to the JavaScript interpreter.

4. Which of the following runs the JavaScript code?
a) Just In Time compiler
b) JavaScript Interpreter
c) Both Just In Time compiler and JavaScript Interpreter
d) None of the mentioned

View Answer

Answer: b [Reason:] The JavaScript Interpreter runs the JavaScript code.

5. Which of the following layer retrieves the content from the network?
a) Transport Layer
b) Application Layer
c) Network Layer
d) Physical Layer

View Answer

Answer: c [Reason:] The network layer retrieves the content from the network.

6. Which of the following gets converted to DOM elements by the rendering engine?
a) Tokens
b) Strings
c) Address
d) All of the mentioned

View Answer

Answer: a [Reason:] The string returned by the network layer gets tokenized into meaningful chunks. The rendering engine then takes the tokens and converts them to DOM elements.

7. Which of the below does not belong to the Render Engine work flow?
a) Paint DOM elements
b) Parse Content
c) Build DOM nodes in render tree
d) None of the mentioned

View Answer

Answer: d [Reason:] All of the mentioned belongs to the Render Engine work flow. The Render engine work flow contains :

  1. Parse Content
  2. Build DOM nodes in render tree
  3. Layout positioning of DOM elements
  4. Paint DOM elements.

8. Which is the next step after retrieving the content in chunks?
a) Paint DOM elements
b) Parse Content
c) Build DOM nodes in render tree
d) None of the mentioned

View Answer

Answer: b [Reason:] After retrieving the content in chunks, the contents will be parsed.

9. What will happen after executing the script?
a) Execute script
b) Layout positioning of DOM elements
c) Paint DOM elements
d) Build DOM nodes in render tree

View Answer

Answer: d [Reason:] After executing the script, the DOM nodes will be built in the render tree.

10. What would happen if there were no script tags?
a) Build DOM nodes in render tree
b) Layout positioning of DOM elements
c) Paint DOM elements
d) Execute script

View Answer

Answer: a [Reason:] If there were no script tags, the DOM nodes will be built in the render tree.

Javascript MCQ Set 3

1. The ‘$’ present in the RegExp object is called a
a) character
b) matcher
c) metacharacter
d) metadata

View Answer

Answer: c [Reason:] The ‘S’ is a special metacharacter that matches the end of a string.

2. Consider the following statement containing regular expressions

var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

In order to check if the pattern matches, the statement is
a) text==pattern
b) text.equals(pattern)
c) text.test(pattern)
d) pattern.test(text)

View Answer

Answer: d [Reason:] The given pattern is applied on the text given in the paranthesis.

3. The regular expression to match any one character not between the brackets is
a) […].
b) [^].
c) [^…].
d) [D].

View Answer

Answer: c [Reason:] The [^…] character class is used to match or draw any one character not between the brackets.

4. What does /[^(]* regular expression indicate ?
a) Match one or more characters that are not open paranthesis
b) Match zero or more characters that are open paranthesis
c) Match zero or more characters that are not open paranthesis
d) Match one or more characters that are open paranthesis

View Answer

Answer: c [Reason:] We should always be careful while using * and ? as repetition characters as they may match zero instances of whatever precedes them, they are allowed to match nothing.

5. What will be the result when non greedy repetition is used on the pattern /a+?b/ ?
a) Matches the letter b preceded by the fewest number of a’s possible
b) Matches the letter b preceded by any number of a
c) Matches letter a preceded by letter b, in the stack order
d) None of the mentioned

View Answer

Answer: a [Reason:] Using non greedy repetition may not always produce the results you expect. /a+?b/ matches the letter b preceded by the fewest number of a’s possible.

6. What does the subexpression /java(script)?/ result in ?
a) It matches “java” followed by the optional “script”
b) It matches “java” followed by any number of “script”
c) It matches “java” followed by a minimum of one “script”
d) None of the mentioned

View Answer

Answer: a [Reason:] The subexpression /java(script)?/ matches “java” followed by the optional “script”.

7. What is the most essential purpose of parantheses in regular expressions ?
a) Define pattern matching techniques
b) Define subpatterns within the complete pattern
c) Define portion of strings in the regular expression
d) All of the mentioned

View Answer

Answer: b [Reason:] When a regular expression is successfullyy matched against a target string, it is possible to extract the portions of the target string that matched any particular paranthesized subpattern. The essential purpose of parantheses in regular expressions is to define subpatterns within the complete pattern.

8. The method that performs the search-and-replace operation to strings for pattern matching is
a) searchandreplace()
b) add()
c) edit()
d) replace()

View Answer

Answer: d [Reason:] The replace() method performs a search-and-replace operation. It takes a regular expression as its first argument and a replacement string as its second argument.

9. What would be the result of the following statement in JavaScript using regular expression methods ?
a) Returns [“123″”456″”789”].
b) Returns [“123″,”456″,”789”].
c) Returns [1,2,3,4,5,6,7,8,9].
d) Throws an exception

View Answer

Answer: b [Reason:] The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.

10. Consider the following code snippet

    var pattern = /Java/g;
    var text = "JavaScript is more fun than Java!";
    var result;
    while ((result = pattern.exec(text)) != null) 
    {
        alert("Matched '" + result[0] + "'" +" at position " + result.index +"; next search begins at " + pattern.lastIndex);
    }

What purpose does exec() solve in the above code ?
a) Returns the same kind of array whether or not the regular expression has the global g flag
b) Returns different arrays in the different turns of iterations
c) All of the mentioned
d) None of the mentioned

View Answer

Answer: a [Reason:] exec() returns the same kind of array whether or not the regular expression has the global g flag. Recall that match() returns an array of matches when passed a global regular expression. exec(), by contrast, always returns a single match and provides complete information about that match. When exec() is called on a regular expression that has the g flag, it sets the lastIndex property of the regular expression object to the character position immediately following the matched substring. When exec() is invoked a second time for the same regular expression, it begins its search at the character position indicated by the lastIndex property. If exec() does not find a match, it resets lastIndex to 0.

Javascript MCQ Set 4

1. How many read-only attributes are present in the navigator object?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: b [Reason:] There are a total of 2 read-only attributes present in the navigator object namely :

  1. redirectCount
  2. type.

2. Why are HTTP redirects significant?
a) TCP connection available
b) Complete roundtrip absent
c) Complete roundtrip present
d) None of the mentioned

View Answer

Answer: b [Reason:] HTTP redirects are significant because they cause a complete roundtrip for each redirect. The original request is returned from the web server as either a 301 or a 302 with the path to the new location. The browser must then initialize a new TCP connection and send a new request for the new location.

3. Where does the DNS reply go to in a single HTTP redirect?
a) Browser
b) Client
c) Server
d) DNS Server

View Answer

Answer: a [Reason:] The DNS reply goes to the Browser in a single HTTP redirect.

4. How can one access the redirectCount property?
a) navigation.redirectCount
b) performance.navigation.redirectCount
c) performance.redirectCount
d) redirectCount

View Answer

Answer: b [Reason:] The redirectCount property can be accessed as : performance.navigation.redirectCount.

5. How many constant values can the property type be represented?
a) 2
b) 3
c) 4
d) 5

View Answer

Answer: c [Reason:] Totally 4 constant values can be represented by the property type.

6. Which of the following constants has the value 255?
a) TYPE_NAVIGATE
b) TYPE_RELOAD
c) TYPE_BACK_FORWARD
d) TYPE_RESERVED

View Answer

Answer: d [Reason:] TYPE_RESERVED: Has the value of 255 and is a catch-all for any navigation type not defined above.

7. What is the purpose of the constant TYPE_RELOAD?
a) Reload performed
b) Reload not performed
c) Reload must be performed
d) None of the mentioned

View Answer

Answer: a [Reason:] TYPE_RELOAD: Has the value of 1, indicating that the current page was arrived at via a reload operation.

8. What does the constant TYPE_BACK_FORWRD indicate?
a) Navigation via browser history
b) Navigation via user request
c) Navigation via URL
d) None of the mentioned

View Answer

Answer: a [Reason:] TYPE_BACK_FORWARD: Has the value of 2, indicating that the page was navigated to via the browser history, either using the back or forward buttons or programmatically through the browser’s history object.

9. Which of the following constants hold the value 2?
a) TYPE_NAVIGATE
b) TYPE_RELOAD
c) TYPE_BACK_FORWARD
d) TYPE_RESERVED

View Answer

Answer: c [Reason:] TYPE_BACK_FORWARD: Has the value of 2, indicating that the page was navigated to via the browser history, either using the back or forward buttons or programmatically through the browser’s history object.

10. Where does the DNS Lookup direct to ?
a) Browser
b) Client
c) Server
d) DNS Server

View Answer

Answer: d [Reason:] The DNS Lookup directs to the DNS Server.

Javascript MCQ Set 5

1. How many read-only attributes are present in the navigator object?
a) 1
b) 2
c) 3
d) 4

View Answer

Answer: b [Reason:] There are a total of 2 read-only attributes present in the navigator object namely :

  1. redirectCount
  2. type.

2. Why are HTTP redirects significant?
a) TCP connection available
b) Complete roundtrip absent
c) Complete roundtrip present
d) None of the mentioned

View Answer

Answer: b [Reason:] HTTP redirects are significant because they cause a complete roundtrip for each redirect. The original request is returned from the web server as either a 301 or a 302 with the path to the new location. The browser must then initialize a new TCP connection and send a new request for the new location.

3. Where does the DNS reply go to in a single HTTP redirect?
a) Browser
b) Client
c) Server
d) DNS Server

View Answer

Answer: a [Reason:] The DNS reply goes to the Browser in a single HTTP redirect.

4. How can one access the redirectCount property?
a) navigation.redirectCount
b) performance.navigation.redirectCount
c) performance.redirectCount
d) redirectCount

View Answer

Answer: b [Reason:] The redirectCount property can be accessed as : performance.navigation.redirectCount.

5. How many constant values can the property type be represented?
a) 2
b) 3
c) 4
d) 5

View Answer

Answer: c [Reason:] Totally 4 constant values can be represented by the property type.

6. Which of the following constants has the value 255?
a) TYPE_NAVIGATE
b) TYPE_RELOAD
c) TYPE_BACK_FORWARD
d) TYPE_RESERVED

View Answer

Answer: d [Reason:] TYPE_RESERVED: Has the value of 255 and is a catch-all for any navigation type not defined above.

7. What is the purpose of the constant TYPE_RELOAD?
a) Reload performed
b) Reload not performed
c) Reload must be performed
d) None of the mentioned

View Answer

Answer: a [Reason:] TYPE_RELOAD: Has the value of 1, indicating that the current page was arrived at via a reload operation.

8. What does the constant TYPE_BACK_FORWRD indicate?
a) Navigation via browser history
b) Navigation via user request
c) Navigation via URL
d) None of the mentioned

View Answer

Answer: a [Reason:] TYPE_BACK_FORWARD: Has the value of 2, indicating that the page was navigated to via the browser history, either using the back or forward buttons or programmatically through the browser’s history object.

9. Which of the following constants hold the value 2?
a) TYPE_NAVIGATE
b) TYPE_RELOAD
c) TYPE_BACK_FORWARD
d) TYPE_RESERVED

View Answer

Answer: c [Reason:] TYPE_BACK_FORWARD: Has the value of 2, indicating that the page was navigated to via the browser history, either using the back or forward buttons or programmatically through the browser’s history object.

10. Where does the DNS Lookup direct to ?
a) Browser
b) Client
c) Server
d) DNS Server

View Answer

Answer: d [Reason:] The DNS Lookup directs to the DNS Server.

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