4/26/2012

Coldfusion fundamental questions


Q1. What will be the output of the following code?(provided the DSN supports multiple query execution on MYSQL or SQL Server).

<cfquery name="get_qry" datasource="#Application.dsn#"> 
    SELECT 1 AS temp; 
    SELECT 2 AS temp; 
    SELECT 'yyy' AS temp 
</cfquery> 
<cfoutput>#get_qry.temp#</cfoutput>

Options:
1. Database execution error.
2.  yyy
3.  1
4.  2
5. 1,2,yyy
6. Coldfusion error.


Q2. While doing any server-side caching of a cfm page using <cfcache>, we should make sure that the page doesn’t depend on which of the following scopes variable.

Options:(select multiple)
1. APPLICATION
2. SERVER
3. SESSION
4. CLIENT
5. CALLER
6. COOKIE

Q3. What dose the following code display. 

<cfoutput>#(TRUE AND (5 * 2) OR 7)#</cfoutput>

Options:
1. TRUE
2. 7 
3. 10
4. (TRUE AND (5 * 2) OR 7)
5. TRUE10
6. False

Q4. What will be the return value of the function written below (provided valid DSN)

<cffunction name="test_function" output="false" access="public"> 
    <cfargument name="test_arg" required="false" default="0"> 
    <cfscript> 
        var returnvar; 
    </cfscript>

    <cfquery name="returnvar" datasource="#Application.dsn#"> 
        SELECT 1 AS temp 
    </cfquery> 
   <cfreturn returnvar.temp> 
</cffunction> 

Options:
1. 1
2. a query object which has a column 'temp' 
3. gives a database execution error. 
4. gives a coldfusion run time error. 
5. gives a coldfusion compile time error. 


Reason(click) :

Q5. If you put <cfabort> at the starting of 'OnRequestStart' function in the application.cfc, then if a missing template request comes to the same coldfusion application, wiil the code inside the 'OnMissingTemplate' function execute?.


Options:
1. YES
2. NO
3. It will put in to a infinite loop.


Q6.What will be the output of the following code. 

<cfscript> 
    test = StructNew(); 
    newTest = test; 
    test.value = "Hello"; 
    test = 45; 
</cfscript>

<cfoutput>#newTest.value# #test#</cfoutput>

Options:
1. Hello Hello
2. 45 Hello
3. Hello 45
4. 45 45 
5. An error would be displayed to the user.


Q7. What will be the output of the following code.

<cfscript>
    Variables[ 'My.Variable.temp.v1' ] = 12;
    Variables.My.Variable.temp.v1 = 13;
    Variables[ 'My' ][ 'Variable' ][ 'temp' ][ 'v1' ] = 14;
</cfscript>


<cfoutput>#StructCount(Variables)#</cfoutput>

Options:
1. An error would be displayed to the user.
2. 4
3. 3
4. 2
5. 1


Q8. What will be the output of the following code.(Assuming clientManagement is true)

<cfscript>
    Session.myVar.a = 1;
    Variables.myVar = Session.myVar;
    Session.myVar.a = 2;
    Client.myVar = Session.myVar;
</cfscript>

 
<cfoutput>#Session.myVar.a##Variables.myVar.a##Client.myVar.a#</cfoutput>



Options:
1. 111
2. 212
3. 112
4. An error would be displayed to the user.


Q9.  What will be the output of the following code.

<cfset myList = 'a'>
<cfset ListAppend(myList, 'c,d')>
<cfset ListDeleteAt(myList,  '1')>

<cfoutput>#ListLast(myList)#</cfoutput>


Options:
1. a
2. c
3.
4. An error would be displayed to the user.


Q10. Which are the following coldfusion scoped variables can't be accessed with out it's scope as prefix. 

 Options:(select multiple)
1. CGI
2. Form
3. Request
4. Session
5. Cookie
6. Attributes
 
 Q11. What will be the output of the following CF code. 


<cffunction name="my_function" access="public">
    <cfreturn arguments>
</cffunction>
<cfset args = {'arg-1'=4, 'arg-2' = 3}>
<cfset call_fun = my_function(argumentCollection = args)>

 

options:
1. Throws an error, as coldfusion doesn't allow hyphens in argument names.
2.The code works fine.