JavaScript Questions & Answers – The Closure Compiler

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “The Closure Compiler”.

1. In how many modes can the closure compiler be run?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: The Closure Compiler is a tool for making JavaScript download and run faster. There are totally 2 modes in which the closure compiler can be run namely:

  1. Simple mode
  2. Advanced mode.

2. What is the purpose of the simple mode?
a) Removes whitespaces
b) Does not remove white spaces
c) Removes the unwanted words
d) Removes characters
View Answer

Answer: a
Explanation: The javascript minifier compresses the javascript code. In Simple mode it mostly performs like most other minifiers, removing whitespace, line breaks, and comments.

3. What is a closure compiler UI?
a) Run time application
b) Web application
c) Standalone application
d) Changes structures
View Answer

Answer: b
Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. A closure compiler UI is a web application.
advertisement
advertisement

4. What are the benefits of closure compiler?
a) Efficiency
b) Code checking
c) Both Efficiency and Code checking
d) Modularity
View Answer

Answer: d
Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. The closure compiler is highly beneficial in terms of:

  • Efficiency: The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs.
  • Code checking: The Closure Compiler provides warnings for illegal JavaScript and warnings for potentially dangerous operations, helping you to produce JavaScript that is less buggy and easier to maintain.

5. In what way is the closure compiler efficient?
a) Increases the size of the JavaScript files
b) Reduces the size of the JavaScript files
c) Reduces the execution time
d) Reduces the speed
View Answer

Answer: b
Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs.

6. In which way can the closure compiler can be used?
a) Open source
b) Run time application
c) Web application
d) Only Open source and Web application
View Answer

Answer: d
Explanation: Closure compiler parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. You can use the Closure Compiler as:

  • An open source Java application that you can run from the command line.
  • A simple web application.
  • A RESTful API.

7. What is the purpose of the advanced mode in the closure compiler?
a) Renames variables
b) Renames function
c) Both Renames variables and function
d) Changes structures
View Answer

Answer: c
Explanation: In Advanced mode it rewrites the JavaScript by renaming variables and functions from longer descriptive names to single letters to save file size, and it inlines functions, coalescing them into single functions wherever it determines that it can.
advertisement

8. Why is a closure template used?
a) Statically updating in JavaScript
b) To increase the efficiency and convenience
c) Dynamically generating HTML in Java and JavaScript
d) Changing code
View Answer

Answer: c
Explanation: Instead of compiling from a source language to machine code, closure templates compiles from JavaScript to better JavaScript. Closure compiler provides with the basic facilities of removing spaces and dead code. Closure Templates are a templating system for dynamically generating HTML in both Java and JavaScript. Because the language was apparently referred to as “Soy” internal to Google, and “Soy” remains in some of the documentation and classes, sometimes Closure Templates are referred to as “Soy Templates”.

9. In what way does the closure compiler help in checking the code?
a) Warnings
b) Suddenly aborts
c) Rejects malicious inputs
d) Terminates the execution
View Answer

Answer: a
Explanation: Closure compiler parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. The Closure Compiler provides warnings for illegal JavaScript and warnings for potentially dangerous operations, helping you to produce JavaScript that is less buggy and easier to maintain.
advertisement

10. What is the function of the closure compiler?
a) Download faster
b) Run faster
c) Both Download faster and Run faster
d) Changes the code
View Answer

Answer: c
Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.

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]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.