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

Summary

Structures provide a way to group related information for quick and easy access. They may be accessed using dot notation and bracket notation (like arrays). Structures may contain arrays, other structures, and more—and may themselves be part of arrays. Many internal ColdFusion variables are structures and may be accessed as such.

Sample Questions

1:Choose the output of the following code:
<cfset a = StructNew()>
<cfset b = a>
<cfset a.myVar = 1>
<cfset b.myVar = 2>
<cfset c = a.myVar + b.myVar>
<cfset c = c * b.myVar>
<cfoutput>#c#</cfoutput>

  1. 4

  2. 8

  3. 16

  4. 36

2:Choose the correct syntax for looping over a structure.
  1. <cfloop collection="struct" item="i">

  2. <cfloop collection="#struct#" item="s">

  3. <cfloop from="#struct#" to="#StructLen(struct)#" index="i">

  4. <cfloop collection="#struct#" index="i">

3:In the following code, which line will throw an error?
<cfset car=StructNew(1)>
<cfset car.make="Acura">
<cfset car.model=TL>
<cfset car.year=2005>

  1. 1

  2. 2

  3. 3

  4. 4

4:Which of these assignments are valid? (select two)
  1. <cfset user.last name="Forta">

  2. <cfset user[lastname]="Forta">

  3. <cfset user.lastname="Forta">

  4. <cfset user."lastname"="Forta">


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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