• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Summary

ColdFusion can do the following: iterate through a set of numeric values; loop while a condition is true; loop over the records of a query; loop over elements of a list; and loop over key-value pairs of a collection. Loops can also be nested.

Sample Questions

1:Which one of the following is not true of index loops?
  1. They can iterate over numeric values.

  2. The loop value variable is assigned using the index attribute.

  3. They can iterate over the alphabet.

  4. They can step by negative increments.

2:What is the output from the following loop?
<!--- Set up variables for condition --->
<cfset NumToGet="3">
<cfset i="1">
<!--- Now loop --->
<cfloop condition="i LTE NumToGet">
 <cfset i=i+1>
 <cfoutput>#i#</cfoutput>
</cfloop>

  1. 1 2 3

  2. 2 3

  3. 1 2

  4. 2 3 4

3:A Collection loop is used to loop over a structure that contains key-value pairs of Animal-Cow, Legs-4, and Tail-Yes. What is the value of the attribute item in the loop?
  1. Animal, Legs, Tail

  2. Animal. Cow, Legs. 4, Tail. Yes

  3. Cow, 4, Yes

  4. Cow, 4, Tail

4:The loop variable is assigned using the index attribute in which types of loops? (select two)
  1. Conditional

  2. Index

  3. Collection

  4. List

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint