CommerceClasses And Modules MCQs
Practice Classes And Modules MCQs for competitive exams.
Classes And Modules MCQs
Practice questions from this topic.
Which looping statement allows XML tags to appear in JavaScript programs and adds API for operating on XML data?
- A. for loop
- B. while loop
- C. for/each loop
- D. all of the mentioned
Correct Answer: C
Consider the following code snippet [ x,y ]=[ y,x ] ; What is the result of the above code snippet?
- A. Throws exception
- B. Swap the value of the two variables
- C. Flashes an error
- D. Creates a new reference object
Correct Answer: C
Consider the following code snippet let x = x + 1 ; console . log ( x ) ; What will be the result for the above code snippet?
- A. 0
- B. Null
- C. ReferenceError
- D. NaN
Correct Answer: D
Consider the following code snippet console . log ( p ) If p is not defined, what would be the result or type of error?
- A. Zero
- B. Null
- C. ReferenceError
- D. ValueNotFoundError
Correct Answer: C
Consider the following code snippet function oddsums ( n ) { let total = 0 , result = [] ; for( let x = 1 ; x <= n; x ++ ) { let odd = 2 * x - 1 ; total += odd; result . push ( total ) ; } return result; } What would be the output if oddsums ( 5 ) ; is executed afted the above code snippet ?
- A. Returns [1,4,9,16,25]
- B. Returns [1,2,3,4,5]
- C. Returns [3,6,9,12,15]
- D. Returns [1,3,5,7,9]
Correct Answer: A
The main difference between the variables declared with var and with let is
- A. var is confined to a particular function but let is not
- B. let is confined to a particular function but var is not
- C. var defines values based on conditions but let does not
- D. none of the mentioned
Correct Answer: B
The let keyword can be used
- A. in a for or for/in loop, as a substitute for var
- B. as a block statement, to define new variables
- C. to define variables that are scoped to a single expression
- D. all of the mentioned
Correct Answer: D
Consider the following code snippet const pi = 3.14 ; var pi = 4 ; console . log ( pi ) ; What will be the output for the above code snippet?
- A. This will flash an error
- B. Prints 4
- C. Prints 3.14
- D. Ambiguity
Correct Answer: A
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
Correct Answer: D
Which was one of the first security subsets proposed?
- A. FBJS
- B. Caja
- C. dojox.secure
- D. ADSafe
Correct Answer: D
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
Correct Answer: A
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()
Correct Answer: B