250+ TOP MCQs on JavaScript Benchmarking and Logging with perfLogger and Answers

Javascript Multiple Choice Questions on “JavaScript Benchmarking and Logging with perfLogger – I”.

1. How many default number methods are available in JavaScript?
a) 5
b) 6
c) 7
d) 8

Answer: c
Clarification: There are a total of 7 default number methods in JavaScript namely:

  1. constructor()
  2. toExponential()
  3. toFixed()
  4. toLocaleString()
  5. toPrecision()
  6. toString()
  7. valueOf()

2. What is the observer effect?
a) Observing influences outcome
b) Observing never influences outcome
c) Observing and the outcome are independent
d) Observing and the outcome are not related

Answer: a
Clarification: The observer effect says that simply observing an act influences its outcome. This is often the result of instruments that, by necessity, alter the state of what they measure in some manner.

3. Which of the following are ways to benchmark code?
a) Timing the code
b) Calculating the number of operations performed
c) Timing the code & Calculating the number of operations performed
d) Calculating the number of lines

Answer: c
Clarification: There are a couple of ways to benchmark code—either by timing it or by calculating the number of operations performed during execution. Both of them help in calculating how efficient and modular the code.

4. How to calculate the run time of a code?
a) Start time – End time
b) End time – Start time
c) Start time/ End time
d) Start time * End time

Answer: b
Clarification: Run-time statements use the static resources created by compile-time statements, but can also create, use, and destroy dynamic resources at run time. The run time of code can be calculated as:
run time = end time – start time

  250+ TOP MCQs on Scripting Java with Rhino and Answers

5. According to the workflow of a runtime logging, what happens after calculating the run time?
a) Display to screen
b) Log to server
c) Either Display to screen or Log to server
d) Server to log

Answer: c
Clarification: According to the workflow of a runtime logging, after calculating the run time, decision boxes are kept that will check to either display to the debug screen or log to the server.

6. Which of the following object is used to post the data to an external process, say savePerfData?
a) XML
b) XBT
c) XHR
d) XTR

Answer: c
Clarification: XHR(XMLHttpRequest) is an API in the form of an object whose methods transfer data between a web browser and a web server. The benchmarking process will call the external process. We use XHR object to post the data to the external process.

7. Where does the external process save the result of the test?
a) Normal file
b) Flat file
c) Folder
d) .exe file

Answer: b
Clarification: A flat file consists of a single table of data. It allows the user to specify data attributes, such as columns and data types table by table, and stores those attributes separate from applications. The external process, say savePerfData should in turn save the results of the test in a flat file.

8. Which function is used to start the time logging?
a) startTimeLogging()
b) start()
c) Loggingstart()
d) startLogging()

Answer: a
Clarification: The function startTimeLogging() is used to start the time logging. The startTimeLogging() method captures the timing data for ad hoc, etc for referencing an uncached document.location.

  250+ TOP MCQs on Augmentation of Classes and Answers

9. Which of the following attribute of form tag is not set by using document object in JavaScript?
a) Target
b) Enctype
c) Action
d) Logging

Answer: d
Clarification: Target, enctype & action can be set by using the document object in JavaScript. The Document object has various properties that refer to other objects which allow access to and modification of document content.

10. What will be the output of the following JavaScript function?

<script type="text/javascript">
var name1 = "";
function DisplayName () {
var name2 = " The Best"; 
document.write(name1+name2); 
}
</script>

a) The Best
b) The Best
c) Object required error
d) Javascript Error

Answer: b
Clarification: The write() method writes HTML expressions or JavaScript code to a document.The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML. The output for the above code is The Best.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top