JavaScript: Closures And Statements Trivia Quiz

11 Questions | Total Attempts: 45

SettingsSettingsSettings
Please wait...
Java Quizzes & Trivia

Questions on closures, groovy truth, control structures, miscellaneous. Abc


Questions and Answers
  • 1. 
    (Fill in the blank) A closure acts like a _______ in the context of an iterative method.
  • 2. 
    Unlike a method a closure can only take one parameter.
    • A. 

      True

    • B. 

      False

  • 3. 
    When you return from a closure which is called by an iterative method, you stop the iteration process.
    • A. 

      True

    • B. 

      False

  • 4. 
    Groovy truth is identical to Java truth.
    • A. 

      True

    • B. 

      False

  • 5. 
    In Java the order of case branches within a switch statement is immaterial.
    • A. 

      True

    • B. 

      False

  • 6. 
    The Groovy for/in loop has the same syntax as Java's for/each loop.
    • A. 

      True

    • B. 

      False

  • 7. 
    The Groovy do statement is identical to Java's do statement.
    • A. 

      True

    • B. 

      False

  • 8. 
    Consider this Groovy method and its invocation: def foo() {  def m = [:]  m.a = 0  m.b = 1 } def val = foo() The variable val:
    • A. 

      Is of type Map

    • B. 

      Is undefined since foo has no return value

    • C. 

      Is of type Integer since the last statement of foo is of type Integer

  • 9. 
    (Fill in the blank) The _____ operator invokes the compareTo method of a class that implements the Comparable interface.
  • 10. 
    Groovy does not have a way to test for reference equality.
    • A. 

      True

    • B. 

      False

  • 11. 
    What does this code do? List numbers = [1,2,3,4] println numbers.collect{it * 2}
    • A. 

      Prints a list of the first four even numbers

    • B. 

      Prints four even numbers each on its own line

    • C. 

      Prints the variable numbers itself

Back to Top Back to top