Java MCQ Number 01061

Java MCQ Set 1

1. The Crockford’s subset doesnot include which function in JavaScript?
a) eval()
b) coeval()
c) equal()
d) equivalent()

Answer

Answer: a [Reason:] The Crockford’s subset does not include the with and continue statements or the eval() function. It defines functions using function definition expressions only and does not include the function definition statement.

2. Why does JavaScript subset disallow == and !=?
a) It uses bitwise checking
b) It uses === and !== instead
c) It uses equals() and notequals() instead
d) None of the mentioned

Answer

Answer: b [Reason:] The subset does not include the comma operator, the bitwise operators, or the ++ and — operators. It also disallows == and != because of the type conversion they perform, requiring use of === and !== instead.

3. What is being imposed on each subset to ensure that it conforms to the subset?
a) A parser to parse the code
b) A parser that parses and adds to the subset
c) A static verifier that parses code
d) All of the mentioned

Answer

Answer: c [Reason:] Each subset is coupled with a static verifier that parses code to ensure that it conforms to the subset.

4. Why was “The Good Parts” designed as a language subset in JavaScript?
a) To improve programmer flexibility
b) To balance the work load of the programmer
c) To create an in-built compiler and interpreter
d) To improve programmer productivity

Answer

Answer: d [Reason:] The Good Parts is a language subset designed for aesthetic reasons and with a desire to improve programmer productivity. There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or “sandbox”.

5. Which is the subset that is a secure container designed for the purpose of safely running untrusted JavaScript?
a) Sandbox
b) The Good Parts
c) Both Sandbox and Good Parts
d) None of the mentioned

Answer

Answer: a [Reason:] There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or “sandbox”.

6. Why is the this keyword forbidden in JavaScript?
a) Highly memory consuming
b) Functions should access the global objects
c) Functions should not access the global objects
d) Very inefficient to use

Answer

Answer: c [Reason:] The this keyword is forbidden or restricted because functions (in non-strict mode) can access the global object through this. Preventing access to the global object is one of the key purposes of any sandboxing system.

7. Which are the two functions that are not allowed in any secure subset?
a) evaluate() and restrict()
b) eval() and the Function() constructor
c) debugger() and test()
d) eval() and debugger()

Answer

Answer: b [Reason:] eval() and the Function() constructor are not allowed in any secure subset because they allow the execution of arbitrary strings of code, and these strings cannot be statically analyzed.

8. Which is the object that defines methods that allow complete control over page content?
a) The client-side document object
b) The server-side document object
c) Both client-side and server-side document object
d) None of the mentioned

Answer

Answer: a [Reason:] The client-side document object defines methods that allow complete control over page content.

9. Which was one of the first security subsets proposed?
a) FBJS
b) Caja
c) dojox.secure
d) ADSafe

Answer

Answer: d [Reason:] ADsafe was one of the first security subsets proposed) It was created by Douglas Crockford (who also defined The Good Parts subset).ADsafe relies on static verification only, and it uses JSLint as its verifier. It forbids access to most global variables and defines an ADSAFE variable that provides access to a secure API, including special-purpose DOM methods. ADsafe is not in wide use, but it was an influential proof-of-concept that influenced other secure subsets.

10. Which is the subset that transforms web content into secure modules that can be safely hosted on a web page?
a) Microsoft Web Sandbox
b) ADsafe
c) Caja
d) dojox.secure

Answer

Answer: d [Reason:] Caja is Google’s open-source secure subset. Caja (Spanish for “box”) defines two language subsets. Cajita (“little box”) is a narrow subset like that used by ADsafe and dojox.secure. Valija (“suitcase” or “baggage”) is a much broader language that is close to regular ECMAScript 5 strict mode (with the removal of eval()). Caja itself is the name of the compiler that transforms (or “cajoles”) web content (HTML, CSS, and JavaScript code) into secure modules that can be safely hosted on a web page without being able to affect the page as a whole or other modules on the page.

Java MCQ Set 2

1. The word “document” mainly refers to
a) Dynamic Information
b) Static Information
c) Both Dynamic and Static Information
d) None of the mentioned

Answer

Answer: b [Reason:] Some pages present static information and can be called documents.

2. Which object is the main entry point to all client-side JavaScript features and APIs?
a) Standard
b) Location
c) Window
d) Position

Answer

Answer: c [Reason:] The Window object is the main entry point to all client-side JavaScript features and APIs. It represents a web browser window or frame, and you can refer to it with the
identifier window.

3. Which identifier is used to represent a web browser window or frame?
a) frames
b) window
c) location
d) frame

Answer

Answer: b [Reason:] The Window object is the main entry point to all client-side JavaScript features and APIs. It represents a web browser window or frame, and you can refer to it with the
identifier window.

4. Which property in the Window object is used to refer to a Location object?
a) position
b) area
c) window
d) location

Answer

Answer: d [Reason:] The Window object defines properties like location, which refers to a Location object that specifies the URL currently displayed in the window and allows a script to load a new URL into the window.

5. Which Window object method is used to display message in a dialog box?
a) alert()
b) prompt()
c) message()
d) none of the mentioned

Answer

Answer: a [Reason:] The Window object also defines methods like alert(), which displays a message in a dialog box.

6. The setTimeout() method is used to
a) Make the event sleep
b) Register a function to be invoked after a certain time
c) Invoke an event after a certain time
d) Time for iteration

Answer

Answer: b [Reason:] The setTimeout(), which registers a function to be invoked after a specified amount of time.

7. Which of the following is a global object?
a) Register
b) Location
c) Window
d) Position

Answer

Answer: c [Reason:] In client-side JavaScript, the Window object is also the global object. This means that the Window object is at the top of the scope chain and that its properties and methods are effectively global variables and global functions.

8. When will the window property come into play?
a) Representation convenience
b) Use as an extension of other objects
c) Use objects in the Window object
d) Refer to window object itself

Answer

Answer: d [Reason:] The Window object has a property named window that always refers to itself. You can use this property if you need to refer to the window object itself, but it is not usually necessary to use window if you just want to refer to access properties of the global window object.

9. Which is the property that represents the content displayed in the window?
a) document
b) content
c) window
d) frame

Answer

Answer: a [Reason:] One of the most important properties of the Window object is document: it refers to a Document object that represents the content displayed in the window.

10. How to pick a document element based on the value of its id attribute?
a) getElementsbyId()
b) getElementbyId()
c) both getElementsbyId() and getElementbyId()
d) none of the mentioned

Answer

Answer: b [Reason:] The Document object has important methods such as getElementById(), which returns a single document element (representing an open/close pair of HTML tags and all of the content between them) based on the value of its id attribute.

Java MCQ Set 3

1. When does WebPageTest become necessary?
a) To run any common website
b) To run private websites
c) To run QA testing
d) All of the mentioned

Answer

Answer: b [Reason:] If you want to run tests on web sites that are not publicly available—like a QA or development environment, or if you can only have your test results stored on your own servers because of legal or other reasons, then installing your own private instance of WebPagetest is the way to go.

2. What is the purpose of Auth tab in the testing platform?
a) To specify credentials
b) To authorize a page
c) To run the test
d) None of the mentioned

Answer

Answer: a [Reason:] In the Auth tab you can specify credentials to use if the web site uses HTTP authentication for access.

3. What is the purpose of the Script tab?
a) To edit the coding
b) To run on multiple servers
c) To run more complex tests
d) None of the mentioned

Answer

Answer: c [Reason:] The Script tab can be used to run more complex tests that involve multiple steps including navigate to multiple URLs, etc.

4. Which is the command that is used to spoof the client user agent?
a) setUserAgent
b) spoofAgent
c) spoofClientUserAgent
d) none of the mentioned

Answer

Answer: a [Reason:] The setUserAgent spoofs the client user agent.

5. What is the purpose of the Block tab?
a) To block the response
b) To block the request
c) To block the mouse pointer
d) None of the mentioned

Answer

Answer: b [Reason:] The Block tab allows us to block content coming in our request.

6. What is the purpose of the Video tab?
a) To take video of the page
b) To capture screenshots of the test only
c) To take video of the test
d) To capture screen shots of the page

Answer

Answer: d [Reason:] The Video tab allows you to capture screen shots of your page as it loads and views them as a video.

7. What is the task of the Advanced Panel?
a) Test stop running
b) Loading the pages
c) Skewing the results
d) None of the mentioned

Answer

Answer: a [Reason:] In the Advanced panel, you can have the test stop running at document completion. That will tell us when the document.onload event is fired, instead of when all assets on the page are loaded.

8. What is the vulnerability of XHR communications?
a) There is no vulnerability
b) Skewing the results
c) Registration and Skewing the results
d) Registering the test results

Answer

Answer: c [Reason:] XHR communications that may happen after page load could register as new activity and skew the test results.

9. Which of the following methods adds and connects the point to the cubic bezier curve?
a) bezierConnect()
b) bezierCurveTo()
c) Connectbezier()
d) none of the mentioned

Answer

Answer: b [Reason:] This method adds a new point P to the subpath and connects it to the current point with a cubic Bezier curve.

10. Which of the following methods adds an arc to the current subpath?
a) bezierCurveTo()
b) arcTo()
c) arc()
d) all of the mentioned

Answer

Answer: c [Reason:] The arc() method adds an arc to the current subpath.

Java MCQ Set 4

1. How does PhantonJS use YSlow?
a) Queries
b) Statements
c) Command Line Prompt
d) Command Line Script

Answer

Answer: d [Reason:] YSlow for PhantomJS is a command line script that allows page performance analysis from live URLs, unlike YSlow for Command Line (HAR) where a pre-generated HAR file is needed in order to analyze page performance.

2. What are the two output formats YSlow uses?
a) TAP, JUnit
b) JIT, TRD
c) JKP, RFD
d) None of the mentioned

Answer

Answer: a [Reason:] YSlow for PhantomJS introduces new output formats for automated test frameworks: TAP (Test Anything Protocol) and JUnit.

3. Initially, YSlow was an extension of which browser?
a) Chrome
b) Firefox
c) IE
d) Opera

Answer

Answer: b [Reason:] Intially, YSlow was an extension of Firefox.

4. Which of the following can be used for a deeper analysis of the web page’s performance?
a) WebPageTest
b) FireBug
c) YSlow
d) All of the mentioned

Answer

Answer: c [Reason:] For a deeper analysis of a page’s web performance you can use YSlow.

5. How many rules are there in the YSlow version 2.0?
a) 23
b) 21
c) 27
d) 33

Answer

Answer: a [Reason:] There are totally 23 rules in the ruleset of YSlow (V2) namely :

  1. Minimize HTTP Requests
  2. Use a Content Delivery Network
  3. Avoid empty src or href
  4. Add an Expires or a Cache-Control Header
  5. Gzip Components
  6. Put StyleSheets at the Top
  7. Put Scripts at the Bottom
  8. Avoid CSS Expressions
  9. Make JavaScript and CSS External
  10. Reduce DNS Lookups
  11. Minify JavaScript and CSS
  12. Avoid Redirects
  13. Remove Duplicate Scripts
  14. Configure ETags
  15. Make AJAX Cacheable
  16. Use GET for AJAX Requests
  17. Reduce the Number of DOM Elements
  18. No 404s
  19. Reduce Cookie Size
  20. Use Cookie-Free Domains for Components
  21. Avoid Filters
  22. Do Not Scale Images in HTML
  23. Make favicon.ico Small and Cacheable

6. Which of the following is mandatory to run before running YSlow?
a) WebPageTest
b) FireBug
c) Both WebPageTest and FireBug
d) None of the mentioned

Answer

Answer: b [Reason:] It is mandatory to run FireBug before running YSlow.

7. How does the YSlow for Mobile work as?
a) Bookwise
b) Booklet
c) Bookmaklet
d) All of the mentioned

Answer

Answer: c [Reason:] The YSlow for Mobile works as bookmaklet.

8. Which network allows you to distribute static assets like images, etc?
a) Content Delivery Network
b) Content Receiving Network
c) System Area Network
d) None of the mentioned

Answer

Answer: a [Reason:] A content delivery network (CDN) allows you to distribute your static assets like images, JavaScript files and stylesheets to geographically distributed servers. This gets the content of your page to your user’s browser faster.

9. What are the three important manipulations done in a for loop on a loop variable?
a) Updation, Incrementation, Initialization
b) Initialization,Testing, Updation
c) Testing, Updation, Testing
d) Initialization,Testing, Incrementation

Answer

Answer: b [Reason:] In a for loop, the initialization, the test, and the update are the three crucial manipulations of a loop variable.

10. Consider the following code snippet

let succ = function(x) x+1, yes = function() true, no = function() false;

What convenience does the above code snippet provide?
a) Functional behaviour
b) Modular behaviour
c) No convenience
d) Shorthand expression

Answer

Answer: a [Reason:] The functions defined in this way behave exactly like functions defined with curly braces and the return keyword.

Java MCQ Set 5

1. An absolute path name begins at the :
a) leaf
b) stem
c) current directory
d) root

Answer

Answer : d [Reason:] None.

2. A relative path name begins at the :
a) leaf
b) stem
c) current directory
d) root

Answer

Answer : c [Reason:] None.

3. In tree structure, when deleting a directory that is not empty :
a) The contents of the directory are safe
b) The contents of the directory are also deleted
c) contents of the directory are not deleted
d) none of the mentioned

Answer

Answer : b [Reason:] None.

4. When two users keep a subdirectory in their own directories, the structure being referred to is :
a) tree structure
b) cyclic graph directory structure
c) two level directory structure
d) acyclic graph directory

Answer

Answer : d [Reason:] None.

5. A tree structure ______ the sharing of files and directories.
a) allows
b) may restrict
c) restricts
d) none of the mentioned

Answer

Answer : c [Reason:] None.

6. With a shared file :
a) actual file exists
b) there are two copies of the file
c) the changes made by one person are not reflected to the other
d) the changes made by one person are reflected to the other

Answer

Answer : d [Reason:] None.

7. In UNIX, a link is :
a) a directory entry
b) a pointer to another file or subdirectory
c) implemented as an absolute or relative path name
d) all of the mentioned

Answer

Answer : d [Reason:] None.

8. The operating system _______ the links when traversing directory trees, to preserve the acyclic structure of the system.
a) considers
b) ignores
c) deletes
d) none of the mentioned

Answer

Answer : b [Reason:] None.

9. The deletion of a link, ________ the original file.
a) deletes
b) affects
c) does not affect
d) none of the mentioned

Answer

Answer : c [Reason:] None.

10. When keeping a list of all the links/references to a file, and the list is empty, implies that :
a) the file has no copies
b) the file is deleted
c) the file is hidden
d) none of the mentioned

Answer

Answer : b [Reason:] None.

11. When a cycle exists, the reference count maybe non zero, even when it is no longer possible to refer to a directory or file, due to _______
a) the possibility of one hidden reference
b) the possibility of two hidden references
c) the possibility of self referencing
d) none of the mentioned

Answer

Answer : c [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.