Commerce

Basic 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?

  1. A. The property will be stored in a cache
  2. B. The loop will not run
  3. C. That property will not be enumerated
  4. D. All of the mentioned
Report Error

One of the special feature of an interpreter in reference with the for loop is that

  1. A. Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property
  2. B. The iterations can be infinite when an interpreter is used
  3. C. The body of the loop is executed only once
  4. D. All of the mentioned
Report Error

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?

  1. A. No, this will throw an exception as only numerics can be used in a for loop
  2. B. No, this will not iterate
  3. C. Yes, this will work
  4. D. No, this will result in a runtime error with the message “Cannot use Linked List”
Report Error

What are the three important manipulations done in a for loop on a loop variable?

  1. A. Updation, Incrementation, Initialization
  2. B. Initialization,Testing, Updation
  3. C. Testing, Updation, Testing
  4. D. Initialization,Testing, Incrementation
Report Error

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?

  1. A. Prints the numbers in the array in order
  2. B. Prints the numbers in the array in the reverse order
  3. C. Prints 0 to the length of the array
  4. D. Prints “Empty Array”
Report Error

The enumeration order becomes implementation dependent and non-interoperable if :

  1. A. If the object inherits enumerable properties
  2. B. The object does not have the properties present in the integer array indices
  3. C. The delete keyword is never used
  4. D. Object.defineProperty() is not used
Report Error

Consider the following statements var count = 0 ; while ( count < 10 ) { console . log ( count ) ; count ++ ; } In the above code snippet, what happens?

  1. A. The values of count is logged or stored in a particular location or storage
  2. B. The value of count from 0 to 9 is displayed in the console
  3. C. An error is displayed
  4. D. An exception is thrown
Report Error

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) ?

  1. A. ==
  2. B. equals
  3. C. equal
  4. D. ===
Report Error

The “var” and “function” are

  1. A. Keywords
  2. B. Declaration statements
  3. C. Datatypes
  4. D. Prototypes
Report Error

When an empty statement is encountered, a JavaScript interpreter

  1. A. Ignores the statement
  2. B. Prompts to complete the statement
  3. C. Throws an error
  4. D. Throws an exception
Report Error

A statement block is a

  1. A. conditional block
  2. B. block that contains a single statement
  3. C. Both conditional block and single statement
  4. D. block that combines multiple statements into a single compound statement
Report Error

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 ++ ; }

  1. A. Code 1
  2. B. Code 2
  3. C. Both Code 1 and Code 2
  4. D. Cannot Compare
Report Error