CommerceBasic And Variables MCQs
Practice Basic And Variables MCQs for competitive exams.
Basic And Variables MCQs
Practice questions from this topic.
What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?
- A. The property will be stored in a cache
- B. The loop will not run
- C. That property will not be enumerated
- D. All of the mentioned
Correct Answer: C
One of the special feature of an interpreter in reference with the for loop is that
- A. Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property
- B. The iterations can be infinite when an interpreter is used
- C. The body of the loop is executed only once
- D. All of the mentioned
Correct Answer: A
Consider the following code snippet function tail ( o ) { for (; o . next; o = o . next ) ; return o; } Will the above code snippet work? If not, what will be the error?
- A. No, this will throw an exception as only numerics can be used in a for loop
- B. No, this will not iterate
- C. Yes, this will work
- D. No, this will result in a runtime error with the message “Cannot use Linked List”
Correct Answer: C
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
Correct Answer: B
Consider the following code snippet function printArray ( a ) { var len = a . length, i = 0 ; if ( len == 0 ) console . log (" Empty Array ") ; else { do { console . log ( a [ i ]) ; } while ( ++ i < len ) ; } } What does the above code result?
- A. Prints the numbers in the array in order
- B. Prints the numbers in the array in the reverse order
- C. Prints 0 to the length of the array
- D. Prints “Empty Array”
Correct Answer: A
The enumeration order becomes implementation dependent and non-interoperable if :
- A. If the object inherits enumerable properties
- B. The object does not have the properties present in the integer array indices
- C. The delete keyword is never used
- D. Object.defineProperty() is not used
Correct Answer: A
Consider the following statements var count = 0 ; while ( count < 10 ) { console . log ( count ) ; count ++ ; } In the above code snippet, what happens?
- A. The values of count is logged or stored in a particular location or storage
- B. The value of count from 0 to 9 is displayed in the console
- C. An error is displayed
- D. An exception is thrown
Correct Answer: B
Consider the following statements switch( expression ) { statements } In the above switch syntax, the expression is compared with the case labels using which of the following operator(s) ?
- A. ==
- B. equals
- C. equal
- D. ===
Correct Answer: D
The “var” and “function” are
- A. Keywords
- B. Declaration statements
- C. Datatypes
- D. Prototypes
Correct Answer: B
When an empty statement is encountered, a JavaScript interpreter
- A. Ignores the statement
- B. Prompts to complete the statement
- C. Throws an error
- D. Throws an exception
Correct Answer: A
A statement block is a
- A. conditional block
- B. block that contains a single statement
- C. Both conditional block and single statement
- D. block that combines multiple statements into a single compound statement
Correct Answer: D
Which is a more efficient code snippet ? Code 1 : for(var num = 10 ;num >= 1 ;num -- ) { document . writeln ( num ) ; } Code 2 : var num = 10 ; while( num >= 1 ) { document . writeln ( num ) ; num ++ ; }
- A. Code 1
- B. Code 2
- C. Both Code 1 and Code 2
- D. Cannot Compare
Correct Answer: A