This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Browser Parsing and Rendering – I”.
1. What is the purpose of a Rendering Engine?
a) Parsing objects in page
b) Drawing all objects in page
c) Both Parsing & Drawing all objects in page
d) Rendering object
View Answer
Explanation: It’s responsible for displaying the web page. The rendering engine parses the HTML and the CSS and displays the parsed content on the screen. A Rendering Engine is generally used for parsing and drawing all of the objects in the page.
2. What is the purpose of the JavaScript Engine?
a) Compiling the JavaScript
b) Interpreting the JavaScript
c) Both Compiling & Interpreting the JavaScript
d) Parsing the javascript
View Answer
Explanation: The JavaScript Engine is generally used for interpreting the JavaScript. It is used to interpret the javascript and execute the javscript on the web page.
3. Which layer is used to handle the HTTP requests?
a) Network Layer
b) Transport Layer
c) Application Layer
d) Presentation Layer
View Answer
Explanation: HTTP is a protocol which allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web and a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. The network layer is used to handle the HTTP requests.
4. The User Interface is taken care of which layer?
a) Transport Layer
b) Network Layer
c) UI Layer
d) Presentation Layer
View Answer
Explanation: The user interface layer represents the front end of the Web Client, and contains the actual GUI elements that users view and click. The UI Layer takes care of the User Interface.
5. Which of the following browsers use Webkit?
a) Chrome
b) Internet Explorer
c) Safari
d) Both Chrome and Safari
View Answer
Explanation: WebKit is a browser engine used in Apple’s Safari browser and other products. Webkit is what Chrome and Safari use, and is your target for most mobile web development since it is used as the layout or rendering engine for Android devices as well as mobile Safari for iOS devices and the Silk browser on Kindle Fires.
6. Which of the following first developed Gecko?
a) Safari
b) Netscape
c) Opera
d) Internet Explorer
View Answer
Explanation: Gecko is the name of the layout engine developed by the Mozilla Project. Gecko was first developed at Netscape, before the Mozilla Project spun out as its own entity, as the successor to the original Netscape rendering engine, back in 1997.
7. Which of the following render HTML?
a) Browsers
b) Email Clients
c) Web Components
d) All of the mentioned
View Answer
Explanation: Rendering Engine takes HTML code and interprets it into what you see visually. More tools than just browsers render HTML, including email clients and web components in other applications.
8. SpiderMonkey was developed by _____________
a) Firefox
b) Internet Explorer
c) Safari
d) Opera
View Answer
Explanation: SpiderMonkey is Mozilla’s JavaScript engine written in C and C++. It is used in various Mozilla products, including Firefox, and is available under the MPL2. SpiderMonkey is the JavaScript engine made by Mozilla that is used in Firefox.
9. Carakan is used by which of the following browsers?
a) Firefox
b) Internet Explorer
c) Safari
d) Opera
View Answer
Explanation: Opera uses Carakan, which was introduced in 2010. Mozilla uses spidermonkey and safari uses nitro javascript engine.
10. Which is the alternate name for JavaScriptCore that is used by Safari?
a) Nitro
b) SpiderMoney
c) Carakan
d) V8
View Answer
Explanation: Safari uses JavaScriptCore, sometimes called Nitro. Opera uses Carakan and Mozilla uses SpiderMonkey.
11. What will be the output of the following JavaScript code?
<p id="demo"></p> <script> function myFunction() { var str = "have best"; var patt = new RegExp("es"); var res = patt.test(str); document.getElementById("demo").innerHTML = res; } </script>
a) true
b) false
c) error
d) undefined
View Answer
Explanation: The test() method tests for a match in a string. This method returns true if it finds a match, otherwise it returns false.
12. What will be the output of the following JavaScript code?
<p id="demo"></p> <script> function myFunction() { var patt = new RegExp("World", "g"); var res = patt.toString(); document.getElementById("demo").innerHTML = res; } </script>
a) /World/g
b) World
c) World/g
d) Undefined
View Answer
Explanation: The toString() method returns the string value of the regular expression. It is found in the regular expression library of Javascript.
13. What will be the output of the following JavaScript code?
<p id="demo"></p> <script> function myFunction() { var str = "Give 100%!"; var patt1 = /\d/g; var result = str.match(patt1); if(result) result=true; else result=false; document.getElementById("demo").innerHTML = result; } </script>
a) True
b) False
c) Error
d) Undefined
View Answer
Explanation: The \d metacharacter is used to find a digit from 0-9. The above code results true if a digit is present in the string.
14. What will be the output of the following JavaScript code?
<p id="demo"></p> <script> function myFunction() { var str = "Is this all there is?"; var patt1 = /\s/g; var result = str.match(patt1); if(result) result=true; else result=false; document.getElementById("demo").innerHTML = result; } </script>
a) true
b) false
c) error
d) undefined
View Answer
Explanation: The \s metacharacter is used to find a whitespace character. A whitespace character can be a space, a tab or a new line character.
15. What will be the output of the following JavaScript code?
<p id="demo"></p> <script> var str = "HELLO, LOOK AT YOU!"; var patt1 = /\bLO/; var result = str.search(patt1); document.getElementById("demo").innerHTML = result; </script>
a) 4
b) 7
c) 3
d) 8
View Answer
Explanation: The \b metacharacter is used to find a match at the beginning or end of a word. The above code returns the position of the occurrence of the pattern at the starting of the word.
Sanfoundry Global Education & Learning Series – Javascript Programming.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Practice Information Science MCQs
- Check JavaScript Books
- Check Programming Books
- Apply for Computer Science Internship
- Practice Programming MCQs