Javascript MCQ Set 1
1. Which are the forms of client-side storage?
a) Web Databases
b) FileSystem API
c) Offline Web Applications
d) All of the mentioned
Answer
Answer: d [Reason:] The various forms of client-side storage are web databases, filesystem API, Offline web applications and cookies.
2. Which is the storage that allows the caching of web pages and their associated resources?
a) Web Databases
b) FileSystem API
c) Offline Web Applications
d) All of the mentioned
Answer
Answer: c [Reason:] HTML5 defines an “Offline Web Applications” API that allows the caching of web pages and their associated resources (scripts, CSS files, images, and so on). This is client-side storage for web applications themselves rather than just their data, and it allows web apps to install themselves so that they are available even when there is no connection to the Internet.
3. Which is the Microsoft’s own proprietary client-side storage?
a) IE User Data
b) Offline Web Applications
c) Cookies
d) All of the mentioned
Answer
Answer: a [Reason:] Microsoft implements its own proprietary client-side storage mechanism, known as “userData,” in IE5 and later. userData enables the storage of medium amounts of string data and can be used as an alternative to Web Storage in versions of IE before IE8.
4. Which object supports Filesystem API?
a) Element
b) File
c) Window
d) DOM
Answer
Answer: b [Reason:] The File object allows user-selected files to be uploaded through an XMLHttpRequest.
5. Which is the most appropriate database for developers requiring huge amount of data?
a) Database
b) Datawarehouse
c) Web databases
d) Access
Answer
Answer: c [Reason:] Developers who need to work with really huge amounts of data like to use databases, and the most recent browsers have started to integrate client-side database functionality into their browsers.
6. The localStorage and sessionStorage belongs to
a) Window object
b) Element object
c) Hash object
d) DOM object
Answer
Answer: a [Reason:] Browsers that implement the “Web Storage” draft specification define two properties on the Window object: localStorage and sessionStorage. Both properties refer to a Storage object—a persistent associative array that maps string keys to string values.
7. What is the main difference between localStorage and sessionStorage?
a) Lifetime
b) Scope
c) Both Lifetime and Scope
d) None of the mentioned
Answer
Answer: c [Reason:] The difference between localStorage and sessionStorage has to do with lifetime and scope: how long the data is saved for and who the data is accessible to.
8. What is the lifetime of the data stored through localStorage?
a) Permanant
b) Temporary
c) Both Permanant and Temporary at times
d) Cannot store
Answer
Answer: a [Reason:] Data stored through localStorage is permanent: it does not expire and remains stored on the user’s computer until a web app deletes it or the user asks the browser (through some browser-specific UI) to delete it.
9. Which is the function used to retrieve a value?
a) get()
b) retrieve()
c) getItem()
d) retrieveItem()
Answer
Answer: c [Reason:] To retrieve a value, pass the name to getItem().
10. Which is the function used to store a value?
a) setItem()
b) set()
c) storeItem()
d) store()
Answer
Answer: a [Reason:] To store a value, pass the name and value to setItem().
Javascript MCQ Set 2
1. In how many modes can the closure compiler be run?
a) 1
b) 2
c) 3
d) 4
Answer
Answer: b [Reason:] There are totally 2 modes in which the closure compiler can be run namely :
- Simple mode
- 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) None of the mentioned
Answer
Answer: a [Reason:] 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) All of the mentioned
Answer
Answer: b [Reason:] A closure compiler UI is a web application.
4. What are the benefits of closure compiler?
a) Efficiency
b) Code checking
c) Both Efficiency and Code checking
d) None of the mentioned
Answer
Answer: d [Reason:] 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
Answer
Answer: b [Reason:] 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
Answer
Answer: d [Reason:] 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) None of the mentioned
Answer
Answer: c [Reason:] 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.
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) All of the mentioned
Answer
Answer: c [Reason:] 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) All of the mentioned
Answer
Answer: a [Reason:] 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.
10. What is the function of the closure compiler?
a) Download faster
b) Run faster
c) Both Download faster and Run faster
d) None of the mentioned
Answer
Answer: c [Reason:] The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. 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.
Javascript MCQ Set 3
1. What kind of scoping does JavaScript use?
a) Literal
b) Lexical
c) Segmental
d) Sequential
Answer
Answer: b [Reason:] Like most modern programming languages, JavaScript uses lexical scoping. This means that functions are executed using the variable scope that was in effect when they were defined, not the variable scope that is in effect when they are invoked.
2. What must be done in order to implement Lexical Scoping?
a) Get the object
b) Dereference the current scope chain
c) Reference the current scope chain
d) None of the mentioned
Answer
Answer: c [Reason:] In order to implement lexical scoping, the internal state of a JavaScript function object must include not only the code of the function but also a reference to the current scope chain.
3. What is a closure?
a) Function objects
b) Scope where function’s variables are resolved
c) Both Function objects and Scope where function’s variables are resolved
d) None of the mentioned
Answer
Answer: c [Reason:] A combination of a function object and a scope (a set of variable bindings) in which the function’s variables are resolved is called a closure.
4. Which of the following are examples of closures?
a) Objects
b) Variables
c) Functions
d) All of the mentioned
Answer
Answer: d [Reason:] Technically, all JavaScript functions are closures: they are objects, and they have a scope chain associated with them.
5. Which of the following uses a lot of CPU cycles?
a) GUI
b) Statically generated graphics
c) Dynamically generated graphics
d) All of the mentioned
Answer
Answer: c [Reason:] Dynamically generating graphics from real-time data uses a lot of CPU cycles.
6. Consider the following code snippet :
var scope = "global scope"; function checkscope() { var scope = "local scope"; function f() { return scope; } return f;
What is the function of the above code snippet?
a) Returns value null
b) Returns exception
c) Returns the value in scope
d) None of the mentioned
Answer
Answer: c [Reason:] The above code snippet returns the value in scope.
7. What is the fundamental rule of lexical scoping?
a) Functions are declared in the scope
b) Functions are executed using scope chain
c) All of the mentioned
d) None of the mentioned
Answer
Answer: b [Reason:] The fundamental rule of lexical scoping is that the JavaScript functions are executed using the scope chain that was in effect when they were defined.
8. What is the opposite approach to the lexical scoping?
a) Literal scoping
b) Static scoping
c) Dynamic scoping
d) Generic scoping
Answer
Answer: c [Reason:] The opposite approach to the lexical scoping is the dynamic scoping.
9. What is the purpose of the dynamic scoping?
a) Variables can be declared outside the scope
b) Variables must be declared outside the scope
c) Variables cannot be declared outside the scope
d) None of the mentioned
Answer
Answer: a [Reason:] Dynamic scoping creates variables that can be called from outside the block of code in which they are defined. A variable declared in this fashion is sometimes called a public variable.
10. Which of the algorithmic languages is lexical scoping standardized in?
a) Ada
b) Pascal
c) Modula2
d) All of the mentioned
Answer
Answer: d [Reason:] Lexical scoping is standardized in all algorithmic languages (ALGOL), such as Ada, Pascal, and Modula2. Additionally, it is used in modern functional languages like ML and Haskel.
Javascript MCQ Set 4
1. Cookies were originally designed for
a) Client-side programming
b) Server-side programming
c) Both Client-side & Server-side programming
d) None of the mentioned
Answer
Answer: b [Reason:] Cookies were originally designed for server-side programming, and at the lowest level, they are implemented as an extension to the HTTP protocol.
2. The Cookie manipulation is done using which property?
a) cookie
b) cookies
c) manipulate
d) none of the mentioned
Answer
Answer: a [Reason:] There are no methods involved: cookies are queried, set, and deleted by reading and writing the cookie property of the Document object using specially formatted strings.
3. Which of the following explains Cookies nature?
a) Non Volatile
b) Volatile
c) Intransient
d) Transient
Answer
Answer: d [Reason:] Cookies are transient by default; the values they store last for the duration of the web browser session but are lost when the user exits the browser.
4. Which attribute is used to extend the lifetime of a cookie?
a) higher-age
b) increase-age
c) max-age
d) lifetime
Answer
Answer: c [Reason:] If you want a cookie to last beyond a single browsing session, you must tell the browser how long (in seconds) you would like it to retain the cookie by specifying a max-age attribute. If you specify a lifetime, the browser will store cookies in a file and delete them only once they expire.
5. Which of the following defines the Cookie visibility?
a) document Path
b) localStorage
c) sessionStorage
d) all of the mentioned
Answer
Answer: d [Reason:] Cookie visibility is scoped by document origin as localStorage and sessionStorage are, and also by document path.
6. Which of the following can be used to configure the scope of the Cookie visibility?
a) path
b) domain
c) both path and domain
d) none of the mentioned
Answer
Answer: d [Reason:] The Cookie visibility scope is configurable through cookie attributes path and domain.
7. How can you set a Cookie visibility scope to localStorage?
a) /
b) %
c) *
d) All of the mentioned
Answer
Answer: a [Reason:] Setting the path of a cookie to “/” gives scoping like that of localStorage and also specifies that the browser must transmit the cookie name and value to the server whenever it requests any web page on the site.
8. Which of the following is a boolean cookie attribute?
a) bool
b) secure
c) lookup
d) domain
Answer
Answer: b [Reason:] The final cookie attribute is a boolean attribute named secure that specifies how cookie values are transmitted over the network. By default, cookies are insecure, which means that they are transmitted over a normal, insecure HTTP connection. If a cookie is marked secure, however, it is transmitted only when the browser and server are connected via HTTPS or another secure protocol.
9. Which of the following function is used as a consequence of not including semicolons, commas or whitespace in the Cookie value?
a) encodeURIComponent()
b) encodeURI()
c) encodeComponent()
d) none of the mentioned
Answer
Answer: a [Reason:] Cookie values cannot include semicolons, commas, or whitespace. For this reason, you may want to use the core JavaScript global function encodeURIComponent() to encode the value before storing it in the cookie.
10. What is the constraint on the data per cookie?
a) 2 KB
b) 1 KB
c) 4 KB
d) 3 KB
Answer
Answer: c [Reason:] Each cookie can hold upto only 4 KB. In practice, browsers allow many more than 300 cookies total, but the 4 KB size limit may still be enforced by some.
Javascript MCQ Set 5
1. What is necessary when we need to create a new field in craft?
a) Type of the input
b) Type of the output
c) Type of the field
d) All of the mentioned
Answer
Answer: c [Reason:] Whenever someone creates a new field in Craft, they must specify what type of field it is.
2. What does the getInputHtml() return?
a) Input
b) Fieldtype’s input HTML
c) Array
d) Value
Answer
Answer: b [Reason:] The method getInputHtml() returns a fieldtype’s input HTML.
3. How many arguments does the getInputHtml() accept?
a) 1
b) 2
c) 3
d) 4
Answer
Answer: b [Reason:] The method getInputHtml(0 accepts two arguments: $name and $value. $name is the name you should assign your HTML input’s name= attribute, and $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
4. Which is the method used to process on the input’s post data before it is saved to the database?
a) prep()
b) settings()
c) defineSettings()
d) prepSettings()
Answer
Answer: d [Reason:] If you need to do any processing on your settings’ post data before they’re saved to the database’s content table, you can do it with the prepSettings() method.
5. What is the purpose of the parameter $name ?
a) Document Name
b) Input Name
c) Output Name
d) ID
Answer
Answer: b [Reason:] The parameter $name is the name you should assign your HTML input’s name= attribute.
6. What does the method defineSettings() return?
a) Array of settings name
b) Array of hash key
c) Array of strings
d) None of the mentioned
Answer
Answer: a [Reason:] The defineSettings() method returns an array whose keys define the setting names, and values define the parameters (the type of value, etc.).
7. What is the purpose of the parameter $value?
a) Field’s expected value
b) Field’s previous value
c) Field’s current value
d) Field’s probability value
Answer
Answer: c [Reason:] The parameter $value is the field’s current value (either from the DB, or the POST data if there was a validation error).
8. When does the defineContentAttribute() method return a false?
a) Data stored in different table
b) Data stored in its own table
c) Data is not stored at all
d) Data is not obtained
Answer
Answer: b [Reason:] If your fieldtype is storing data in its own table, and doesn’t have any use for a column within the main content table, you may also set defineContentAttribute() to return false.
9. How many events does the BaseFieldType provide?
a) 1
b) 2
c) 3
d) 4
Answer
Answer: c [Reason:] BaseFieldType provides three events that you can latch code onto:
- onBeforeSave() : Called right before a field is saved.
- onAfterSave() : Called right after a field is saved, and $this->model->id is set.
- onAfterElementSave() : Called right after an element is saved, and $this->element->id is set.
10. Which method is called right before a field is saved?
a) onBeforeSave()
b) BeforeSave()
c) SaveBefore()
d) None of the mentioned
Answer
Answer: a [Reason:] The method onBeforeSave() is called right before a field is saved.
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