Monday, August 30, 2010

COLDFUSION INTERVIEW QUESTIONS

Coldfusion Interview Questions Copied from various sites:
ColdFusion Technical Questions and Answers
1) What exactly is ColdFusion ?
Cold fusion is the only software which helps the programmer to develop dynamic websites with backend database. ColdFusion is the only website which helps in developing dynamic websites. This is useful in software development. This has an application server and software development framework which greatly aid in developing computer software.
2) Describe in detail about programming details in ColdFusion?
ColdFusion differs from major languages such as JSP, ASP.NET or PHP due to its associated scripting language and ColdFusion markup language. The syntax closely resembles to HTML. This language supports server side Action script and embedded scripts which can be written in ColdFusion script. This script is used for data driven websites. This technology also supports languages such as Flex which is used for client side scripting. This has many interfaces embedded in it which allows for services such as SMS and instant messaging.
3) Explain about some of the features present in ColdFusion MX7?
This edition from adobe was named as Macromedia ColdFusion MX7. Some of the features which are present are web forms, Xforms, adobe acrobat friendly report builder, flash, excel and rich text format style. This edition of cold fusion provided Gateways which helped in connecting various services such as IM, SMS, etc.
4) Is it possible to write cold fusion in cold fusion?
No it is not possible to write ColdFusion in ColdFusion. Actually ColdFusion was written in Java and to write programs we need to implement other kinds of programs such as Java, .NET etc. These programs are required because ColdFusion alone cannot survive.
5) Can we modify ColdFusion server code and what are the two open source CFML parsing engines?
Server code of ColdFusion cannot be viewed or modified. The language of ColdFusion itself is documented and subjected to rights laid down by adobe. The two open source engines which are parsing ColdFusion’s markup languages are Blue dragon and Smith project. Blue dragon is a J2EE version.
6) What are the benefits of multiple server instances?
The benefits of multiple server instances are, a single server is enough to deploy a host of applications which makes it highly applicable this was not the case when MX7 was present. Applications running on a server need not be stopped for maintenance as the work and load is shared upon multiple servers. Security, optimized applications and clustering are some of the main benefits of Adobe cold fusion multiple server instances.
7) Describe about Clustering
In previous installations of Adobe cold fusion multiple servers were required to run the application but adobe cold fusion 8 mitigated the problem by clustering Coldfusion into multiple physical installations which take over the load if any application fails during its course of time. This also allows in easy maintenance and possible reduction in maintaining multiple servers. This was made possible by J2EE server.
8) Describe about the level of security a firm can have while running adobe cold fusion?
Cold fusion 8 has enhanced security features, it provides multiple adobe cold fusion installations on the server which necessarily removes the threat of accidental deletion, intrusion, addition, etc because the remote lies with multiple administrators and they can set permissions and access. Data sources, Cold fusion components and custom tags can be differentiated on their work accordingly.
9) How one can provide secured internet applications using adobe ColdFusion?
The three major internet security threats are
1) Memory leak during transmit of information
2) Impersonation which is like an exact clone which enters as legitimate
3) Unauthorized access
These mechanisms are handled by adobe by using Data encryption, User Authentication and Access control.
10) Explain about ColdFusion administrator?
ColdFusion administrator is a web based application just like the Cpanel this has many sub options through which you can control many functions such as data sources, global server settings, debugging settings, and application security settings. If you are having multiple administrator services then password must be provided for all those services. Also multiple user instances are provided where by a server can be split into cluster of Coldfusion administrators where a specific work can be provided to a specific individual who cannot alter changes.
11) Is there any facility which prevents viewing of source code?
ColdFusion has a utility called cfencode which blocks viewing of the source code on coldfusion pages which has an application. Although guarantee of this product is not guaranteed, to an extent this can block viewing of source code altogether. As ColdFusion runs on a web server source code can be blocked completely.
12) Describe about string encryption?
CFML language provides a 32 bit encryption which is symmetric key based. This function is called as Encrypt. Cold fusion at present uses 32 bit encryption but if your application requires 1024 bit encryption you can happily use that function because cold fusion integrates with third party libraries. Cold fusion also uses Hash function which is very important in safeguarding passwords. They use MD5 and XOR based algorithm.
13) What is cold fusion component roles implementation?
Cold fusion component roles implementation allows users to log into their role based administrator support function and not any other function. If a user tries to enter into other functions an error is thrown. These roles and components are taken by the Cold fusion. These roles and functions are transmitted through action script which allows the users to work on their components.
14) What is CFCHART engine?
This CFCHART provides more than 200 different attributes which can be altered and these attributes can be used to control animation, labels, and colors. This CFCHART engine is used to produce high quality graphs, charts, sketches, and these charts can also aid you in Business analysis. These charts aid you very much in developing a good business presentation as you can control every part of it.
15) Which tag aids us in Debugging and attribute in inter site scripting attack?
The tag which aids you in debugging is cftimer tag; this tag gives you the exact time which happens between executions of each line of code. cfapplication helps you prevent intersite scripting attack.
16) Explain about enterprise manager?
Enterprise manager helps you in admin functions. This will help you to create multiple cf server instances, through which you can experience advanced security, performance, and savings.
17) What is the benefit of extensible gateway architecture?
Developers can benefit from extensible gateways by limitless variety of emerging protocols. Developers can benefit by the creation of event gateways.
18) What are the different types of resources through which cold fusion can communicate?
(i) Mobile phones that support SMS
(ii) XMPP or Lotus IM clients
(iii) Java sockets
(iv) Java messaging service
(v) Content management systems and file systems
(vi)
19) What are the two primary types of files in a cold fusion application?
There are two primary types of file systems in ColdFusion which are used extensively they are Coldfusion templates and coldfusion pages. Developers in addition to these use CFML. These can contain HTML and often CFML for Dynamic content.
20) State and explain about integrating Coldfusion applications with JSP.
A cold fusion page can contain JSP or a servlet and a JSP page can contain Coldfusion applications. This facilitates easy access to build hybrid functions and applications which can combine coldfusion components and servlets. How would you loop through a SQL result set stored in the CF variable named my “results” and output the result set columns named “cola” and “colb” in an html table?
<table>
<cfoutput query=”results”>
<tr>
<td>#cola#</td>
<td>#colb#</td>
</tr>
</cfoutput>
</table>
Source: http://www.coders2020.com/interview/coldfusion_interview_questions

Given the url http://localhost/test.cfm?printmesg=yes How would you write an if statement which would echo the message “hello world!” if the url parameter printmesg equals “yes”.
<cfif isDefined(“url.printmesg”) and url.printmesg IS “yes”>
hellol world!
</cfif>
When is it appropriate to use <cfparam> versus <cfset>?
<cfparam> allows you to set a default parameter if that variable does not have a value bound to it.
<cfset> merely sets the value of a given variable.
Given the datasource named “mydb” and a SQL stored procedure named “mystoredproc” which takes the following two parameters one VARCHAR param and one INTEGER parameter respectively, how would you declare this using the cold fusion tags <cfstoredproc>, <cfprocparam>, and <cfprocresult>?
<cfset param1 = “this is my test string”>
<cfset param2 = 1>
<cfstoredproc datasource=”mydb” procedure=”mystoredproc”>
<cfprocparam type=”IN” cfsqltype=”CF_SQL_VARCHAR” dbvarname=”@parama”
value=”#param1#”>
<cfprocparam type=”IN” cfsqltype=”CF_SQL_INTEGER” dbvarname=”@paramb”
value=”#param1#”>
<cfprocresult name=”myprocresult”>
</cfstoredproc>
How do you call a module named “testmod.cfm” with the parameters param1=”yes” and param2=5?
<cfmodule template=”testmod.cfm”
param1=”yes”
param2=5>
When is it appropriate to use <cfinclude> versus <cfmodule>?
Given two tables:
movie
——————
| id |
|—————-|
| title |
| rating |
| length |
| country |
——————
actor
——————
| id |
|—————-|
| movie_id |
| name |
——————
How would you write a SQL statement to find the names of all the actors associated with a movie titled “fight club”?
SELECT actor.name
FROM movie INNER JOIN actor ON movie.id = actor.movie_id
WHERE movie.title = ‘Fight Club’
movie
——————
| id |
|—————-|
| title |
| rating |
| length |
| country |
——————
director
——————
| id |
|—————-|
| movie_id |
| name |
——————
How would you write a LEFT JOIN statement to return a result set of movie.title’s and director.name’s?
SELECT
movie.title,
director.name
FROM movie LEFT JOIN director ON movie.id = director.movie_id
If there are no indices defined on any of the columns in the above two tables, which columns would you index to speed up the LEFT JOIN query?
movie_id
How would you write a simple stored procedure in TSQL which takes a movie_id and returns all the directors associated with it?
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].getDirector (
@movie_id INT
)
SELECT name FROM directors WHERE movie_id = @movie_id
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
What are the advantages and disadvantages of using stored procedures versus calling SQL inline in Cold Fusion?
Stored procedures abstract database logic from server side code. They also offer performance benefits in pushing application logic to the database side.
The disadvantage is that if they are poorly written then they can hinder database performance and make development a little more obfuscated.
How would you format some text using css to be verdana and bold?
.myfontclass {
font-family: Verdana;
font-weight: bold;
}
What is the difference between absolute and relative div positioning?
Absolute is from the absolute 0,0 position in the top left corner of the browser window. Relative is relative from the positioning of where the div is declared within the html body.
How would you declare an inline css to format the table with a background color of “yellow” and give the table cell a right margin of 10 pixels?
<style>
table {
background-color: yellow;
}
td {
margin: 0 10px 0 0;
}
</style>
<table>
<tr>
<td>Hello world</td>
</tr>
</table>
Part-ii
1. Which path is used in the template attribute in the tag?
A. physical path
B. calling template relative path
C. web document root relative path
D. any directory under Cfusion\CustomTags
The correct answer is B.
2. Which of the following would be the last one to capture an exception?
A. <CFCATCH>
B. <CFERROR TYPE=”Request”>
C. <CFERROR TYPE=”Exception”>
D. site-wide error handler specified in the ColdFusion Administrator
The correct answer is D.
3. Of these tags with errors, which could NOT be caught with a block?
A. <CFSET X = 5 / 0>
B. <CFEST X = 5 / 0>
C. <CFSET X = “Y” + 1>
D. <CFINCLUDE TEMPLATE=”file.cfm”> where file.cfm is NOT found
The correct answer is B.
4. If you have the following variable definition in the Application.cfm file, what is the scope of the variable after it is created?
<CFSET x = “foo”>
A. Variables (local)
B. Application
C. Session
D. Request
The correct answer is A.
5. What is the purpose of the GetAuthUser() function?
A. To log in a specified user
B. To return the name of a logged in user who is requesting the page on which the function is used
C. To retrieve user details from a specified data source
D. To assign roles to the user who is requesting the page on which the function is used
The correct answer is B.
6. Which of the following variable types requires the use of the scope when referencing the variable? (Choose two)
A. request
B. form
C. local
D. application
E. URL
The correct answer is A and D.
7. Which function is necessary when using CACHEDWITHIN attribute with the <CFQUERY> tag?
A. CreateDateTime()
B. ParseDateTime()
C. CreateTimeSpan()
The correct answer is C.
8. What is missing from the following <CFQUERY> tag’s SELECT statement if you want to return the count?
<CFQUERY NAME=”test” DATASOURCE=”test”>
SELECT Count(*)
FROM TestTable
</CFQUERY>
A. SELECT Count(CountVar)
B. SELECT Count(*) AS CountVar
C. SELECT Count(*) INTO CountVar
D. SELECT Count(*) <CFQUERYPARAM NAME=”CountVar”>
The correct answer is B.
9. Which of the following ANSI standard WHERE clauses will return all rows where City begins with the letter ‘S’?
A. WHERE City LIKE “S”
B. WHERE City = ‘S*’
C. WHERE City LIKE ‘S_’
D. WHERE City LIKE ‘S%’
The correct answer is D.
10. Which one of the following tags is used for server-side validation? (Choose one.)
A. input type =”text”
B. input type=”hidden”
C. input value=”hidden”
D. input value=”text”
The correct answer is B.
11. When will the cookie created by the following tag expire?
<CFCOOKIE name=”bgcolor” value= “bgcolor”>
A. never
B. after one day
C. when the last browser window is closed
D. after the timeout period for session variables has elapsed
The correct answer is C. source:
source: http://patrickrayes.wordpress.com/2007/04/15/coldfusion-interview-questions-part-i/
1. Explain the structure of Cold fusion?
ColdFusion is implemented on the J2EE. J2EE is a standard, it is not a programming language. J2EE is an implementation of the Java programming language, but includes a number of Application Programming Interfaces (APIs) for connecting to databases, queuing messages, connecting to registries and naming and directory services.
All of these APIs are used by coldfusion for many of its base services and other runtime services.

ColdFusion consists of following components:
* cf script
* CFML
* ColdFusion Administrator
* Verity Search Server
2. What is Web Server?
A computer that delivers (serves up) Web pages. Every Web server has an IP address and possibly a domain name. For example, if you enter the URL http://www.domainname.com/index.html in your browser, this sends a request to the server whose domain name is domainname.com. The server then fetches the page named index.html and sends it to your browser.
Any computer can be turned into a Web server by installing server software and connecting the machine to the Internet. There are many Web server software applications, including public domain software from NCSA and Apache, and commercial packages from Microsoft, Netscape and others.
3. What is Application Server?
A server that exposes business logic to client applications through various protocols including HTTP, HTTPS, IIOS/SSL. Eg: Sun Java Application server, weblogic server
It takes care of important issues like Transaction Management, Security, Database Connection Pooling, Clustering, Scalability,session management,load balancing,thread management and Messaging etc. A web server cannot provide these.
4. How can you communicate with web server (Apache or IIS) from Coldfusion?
Cold Fusion is an example of a Common Gateway Interface application. The Common Gateway Interface is a mechanism to allow Web servers, which are designed to serve static documents, to receive dynamic output from programs and serve it as if it were static data.

1. When a browser sends a request for a Cold Fusion template to a Web server, several things must happen. First, the Web server recognizes the information from the browser as a request for CGI output.
2.If the request was initiated from a form, the server has to write the form field information to some area in storage that is accessible to other programs on the machine. Usually, this is done by using STDOUT data streams. The WinCGI interface, which can be used by WebSite and other servers, writes the form data to INI-style files on disk, which are then opened and read by the CGI application.
3.The CGI program requests data from the data source, which is returned in step
4. The CGI program formats the data as HTML output, returning this output to the server in step
5. The server receives this output, performs any further server-side processing necessary, and then sends it to the browser.

Cold Fusion defaults to using server API modules instead of CGI to communicate between the Web Server and ColdFusion Application Server.
5. What are the advantages of Cold fusion?
Simplified Installation and Migration
All Operating System (OS) Support
All Database support
Faster Development & Easy to Learn
Improved & support for all Protocols
access to all the J2EE libraries
Integration with Other adobe Products (Flex, Flash, PDF..)

6. Compare Cold fusion with other programming languages?
For every language has its pros and cons. Q5 is answer for this also, But I will point out one or 2 advantages of CF over other languages.
vs PHP : Ajax features, Integration with adobe products, community support, J2EE
vs Java : Easy to learn, Code developmet & maintence cost
vs .NET : All OS, Most of webserver Support

7. What is the benefit of using Cold fusion from Developer point of view?
See Q5 & Q6

8. What is the benefit of using Cold fusion from Client point of view?
See Q5 & Q6
9. Difference between Cold fusion 5 and Cold fusion MX 6?
All versions of ColdFusion prior to 6.0 were written using Microsoft Visual C++. CF MX 6.0 move to the Java-based architecture. Major things introduced in CFMX (MX - Matrix, Code name is NEO - hero of Matrix). I pointed out some of them below,

Mac,Linux OS support
Flash Remoting
ability to code and debug Flash
API was released with an OOP
Added Verity Searches
10. Difference between Cold fusion MX 6 and Cold fusion MX 7?
Windows authentication introduced thorough "cfntauthenticate" tag
cfcompile utility introduced which used for Sourceless deployment
Administrator API: Change ColdFusion settings programmatically, without logging into the CF Administrator.
Gateways: SMS, IM (based on Extensible Messaging and Presence Protocol) gateways introduced
Flash forms , Skinnable XML forms introduced
New report builder introduced
11. What is “Application.cfm”?
When ColdFusion receives a request for an application page, it searches the page's directory for a file named Application.cfm. If one exists, the Application.cfm code is logically included at the beginning of that application page.
If your application runs on a UNIX platform, which is case-sensitive, you must spell Application.cfm with an initial capital letter.
12. Can we have multiple “Application.cfm” file in an Application?
Yes. If the application page directory does not have an Application.cfm page, ColdFusion searches up the directory tree until it finds an Application.cfm page. If several directories in the directory tree have an Application.cfm page, ColdFusion uses the first page it finds. If the Application.cfm page is present in the directory tree (and has the required permissions set), you cannot prevent ColdFusion from including it.
ColdFusion processes only one Application.cfm page for each request. If a ColdFusion page has a cfinclude tag pointing to an additional ColdFusion page, ColdFusion does not search for an Application.cfm page when it includes the additional page.
13. What is the working process for “Application.cfm”?
Q12 have answer for this question also
14. Scenario: You have “Application.cfm” in your Root directory, another “Application.cfm” file in child directory. If you are running a cold fusion page from child directory what will happen? Which one (Application.cfm) will execute? Whether both or?
You already have the answer for this question in the 12th question. :)
15. What is cfapplication tag?
It defines the scope of a ColdFusion application; enables and disables storage of Client variables; specifies the Client variable storage mechanism; enables Session variables; and sets Application variable time-outs.
16. What all are the attributes in cfapplication?
Attribute Description
name Name of application. Up to 64 characters.For Application and Session variables: Required. For Client variables: Optional
applicationTimeout Lifespan of application variables. CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas.
clientManagement yes: enables client variables.no
clientStorage How client variables are stored:datasource_name: in ODBC or native data source. You must create storage repository in the Administrator.registry: in the system registry.cookie: on client computer in a cookie. Scalable. If client disables cookies in the browser, client variables do not work.
loginStorage cookie: store login information in the Cookie scope.session: store login information in the Session scope.
scriptProtect Specifies whether to protect variables from cross-site scripting attacksnone: do not protect variablesall: protect Form, URL, CGI, and Cookie variablescomma-delimited list of ColdFusion scopes: protect variables in the specified scopes.For more information, see Usage.
secureJSON A Boolean value that specifies whether to add a security prefix in front of any value that a ColdFusion function returns in JSON-format in response to a remote call. The default value is the value of the Prefix serialized JSON setting in the Administrator Server Settings > Settings page (which defaults to false). You can override this variable value in the cffunction tag.For more information see
secureJSONPrefix The security prefix to put in front of the value that a ColdFusion function returns in JSON-format in response to a remote call if the secureJSON setting is true. The default value is the value of the Prefix serialized JSON setting in the Administrator Server Settings > Settings page (which defaults to //, the JavaScript comment character).
sessionManagement yes: enables session variables.no
sessionTimeout Life span of session variables. CreateTimeSpan function and values in days, hours, minutes, and seconds, separated by commas.
setClientCookies yes: enables client cookies.no: ColdFusion does not automatically send CFID and CFTOKEN cookies to client browser; you must manually code CFID and CFTOKEN on the URL for every page that uses Session or Client variables.
setDomainCookies yes: uses domain cookies for CFID and CFTOKEN cookies and for all Client variables when using cookies for client variable storage. Required for applications running on clusters.no: uses host-specific cookies for CFID, CFTOKEN, and all client variable cookies.
17. How can you set the Client Management?
We can enable & disable client management as well as we can configure How & Where client variables need to be store
1. In the Application.cfc initialization code
This.clientmanagement="True" / "false"
This.clientStorage="[Ur_datasource_name]" / "registry" / "cookie"
2. In appliation.cfm using <cfappliaction> tag attributes
clientManagement="yes" / "no"
clientStorage="[Ur_datasource_name]" / "registry" / "cookie"
[Ur_datasource_name] - Stored in ODBC or native data source. You must create storage repository in the Administrator.
registry - Stored in the system registry.
cookie - Stored on client computer in a cookie. Scalable. If client disables cookies in the browser, client variables do not work.
18. How can you set the Session Management?
Same as client management description in Q17 sessionmanagement variable available, we can use that variable.
19. What are Session Timeout and Application Timeout? Where we have to do this process?
ApplicationTimeout : The time span an application will exist before it times out (if the application is not accessed in any way). This defaults to the value set in the ColdFusion administrator.
SessionTimeout : The time span a session will exist before it times out (if the application is not access in any way by that session's user). This defaults to the value set in the ColdFusion administrator.
20. How can you clear the cache?
To Flush cached queries <cfobjectcache action="clear">
To Flush cached pages <cfcache action="flush">
21. What is Scope Variables?
A variable's scope is determined by its origin. The scope determines a number of properties about the variable, such as its life span, timeout, and storage location, and therefore, how it can be used.
22. What is the different type of Scope variables?
Scope Description
Application Contains variables that are associated with one, named application on a server. The cfapplication tag name attribute or the Application.cfc This.name variable setting specifies the application name.
Arguments Variables passed in a call to a user-defined function or ColdFusion component method.
Attributes Used only in custom tag pages and threads. Contains the values passed by the calling page or cfthread tag in the tag's attributes.
Caller Used only in custom tag pages. The custom tag's Caller scope is a reference to the calling page's Variables scope. Any variables that you create or change in the custom tag page using the Caller scope are visible in the calling page's Variables scope.
CGI Contains environment variables identifying the context in which a page was requested. The variables available depend on the browser and server software.
Client Contains variables that are associated with one client. Client variables let you maintain state as a user moves from page to page in an application, and are available across browser sessions. By default, Client variables are stored in the system registry, but you can store them in a cookie or a database. Client variables cannot be complex data types and can include periods in their names.
Cookie Contains variables maintained in a user's browser as cookies. Cookies are typically stored in a file on the browser, so they are available across browser sessions and applications. You can create memory-only Cookie variables, which are not available after the user closes the browser. Cookie scope variable names can include periods.
Flash Variables sent by a Flash movie to ColdFusion and returned by ColdFusion to the movie.
Form Contains variables passed from a Form page to its action page as the result of submitting the form. (If you use the HTML form tag, you must use method="post".)
function local Contains variables that are declared inside a user-defined function or ColdFusion component method and exist only while a function executes.
Request Used to hold data that must be available for the duration of one HTTP request. The Request scope is available to all pages, including custom tags and nested custom tags, that are processed in response to the request. This scope is useful for nested (child/parent) tags. This scope can often be used in place of the Application scope, to avoid the need for locking variables. Several chapters discuss using the Request scope.
Server Contains variables that are associated with the current ColdFusion server. This scope lets you define variables that are available to all your ColdFusion pages, across multiple applications.
Session Contains variables that are associated with one client and persist only as long as the client maintains a session. They are stored in the server's memory and can be set to time out after a period of inactivity.
This Exists only in ColdFusion components or cffunction tags that are part of a containing object such as a ColdFusion Struct. Exists for the duration of the component instance or containing object. Data in the This scope is accessible from outside the component or container by using the instance or object name as a prefix.
ThisTag Used only in custom tag pages. The ThisTag scope is active for the current invocation of the tag. If a custom tag contains a nested tag, any ThisTag scope values you set before calling the nested tag are preserved when the nested tag returns to the calling tag. The ThisTag scope includes three built-in variables that identify the tag's execution mode, contain the tag's generated contents, and indicate whether the tag has an end tag. A nested custom tag can use the cfassociate tag to return values to the calling tag's ThisTag scope.
Thread Variables that are created and changed inside a ColdFusion thread, but can be read by all code on the page that creates the thread. Each thread has a Thread scope that is a subscope of a cfthread scope.
thread local Variables that are available only within a ColdFusion thread.
URL Contains parameters passed to the current page in the URL that is used to call it. The parameters are appended to the URL in the format ?variablename = value[&variablename=value...]; for example www.MyCompany.com/inputpage.cfm?productCode=A12CD1510&quantity=3. Note: If a URL includes multiple parameters with the same name, the resulting variable in the ColdFusion URL scope consists of all parameter values separated by commas. For example, a URL of the form http://localhost/urlparamtest.cfm? param=1&param=2&param=3 results in a URL.param variable value of 1,2,3 on the ColdFusion page.
Variables (local) The default scope for variables of any type that are created with the cfset and cfparam tags. A local variable is available only on the page on which it is created and any included pages (see also the Caller scope).

23. What is Application Variables? How can you clear these variables?
These are special scope variables that are available to all pages in an application for all clients.
Data is stored in application server memory.
You must use the Application scope prefix in the variable name.
view plaincopy to clipboardprint?
1. <!--- To delete all application variables--->
2. <cfset StructClear(Application)>
3. <!--- To delete a particular variable in session --->
4. <cfset StructDelete(Application, "varName")>

24. What is Session Variables? How can you clear these variables?
These are special scope variables that are available for a single client browser for a single browser session in an application.
Data is stored in application server memory.
You must use the Session scope prefix in the variable name.
view plaincopy to clipboardprint?
1. <!--- To delete all session variables --->
2. <cfset StructClear(Session)>
3. <!--- To delete a particular variable in session --->
4. <cfset StructDelete(Session, "varName")>
25. How can you list out all the Session variables in an Application?
use cfdump to show entire session value in Development environment.
view plaincopy to clipboardprint?
1. <cfdump var="#session#">
Session variables are in stored in structure format. So you loop through the collection to show the session variables.
view plaincopy to clipboardprint?
1. <cfoutput><cfloop collection=#session# item="key">
2. #key# : #structFind(session,key)#
3.
4. </cfloop></cfoutput>
26. How can you delete the session variables?
view plaincopy to clipboardprint?
1. <!--- To delete all session variables --->
2. <cfset StructClear(Session)>
3. <!--- To delete a particular variable in session --->
4. <cfset StructDelete(Session, "varName")>

27. What is a client variable?
These are special scope variables that are available for a single client browser over multiple browser sessions in an application.
Data is stored as cookies, database entries, or Registry values.
No need to use the Client scope prefix in the variable name
Value must be simple variables. Can not be arrays, structures, query objects, or other objects.
28. What is the default storage for client variable?
client variables stored in registry, database or in client cookie.By default, ColdFusion stores this in the Registry.it is more appropriate to store the information as client cookies or in a SQL database.
29. What is URL token?
Combination of CFID & CFTOKEN is called as urltoken. If user disabled the browser cookie, It is used to track a user's browser session.
30. What is Cookie Variables?
Cookies are server specific simply stored variables stored in files in the browser's file system. It used to track state maintenance(browser session) of a user.
31. What is the difference between Client and Session variables?
Session variables can be used to dump complex data structures like arrays and structures.But client variable are used only in case of simple variables.
32. What is Structure? What are the different functions in Structure?
ColdFusion structures consist of key-value pairs. Structures let you build a collection of related variables that are grouped under a single name. A structure's key must be a string. The values associated with the key can be any valid ColdFusion value or object. It can be a string or integer, or a complex object such as an array or another structure. Because structures can contain any kind of data they provide a very powerful and flexible mechanism for representing complex data. check Structure functions here.
33. What is the difference between Structure and Array?
In structure one can combine variables of different datatype in to a common data type Whereas arrays are sequentially stored values of the same datatype.
34. How can you set common footer?
Using cfinclude, we can include footer file in all pages. We can OnRequestEnd.cfm file or OnRequestEnd method in Application.cfc also to include footer file.
35. What is OnRequestEnd.cfm? When it will execute?
Just as the Application.cfm page runs before the code on an application page, an OnRequestEnd.cfm page runs, if it exists, after each application page in the same application.The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory, so it does not run an OnRequestEnd.cfm page that resides in another directory.The OnRequestEnd.cfm page does not run if there is an error or an exception on the application page, or if the application page executes the cfabort or cfexit tag. Page flow given below

Application.cfm -> CFM page -> OnRequestEnd.cfm

36. Can we have multiple OnRequestEnd.cfm in an Application? How its works?
Yes, We can have. The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory
39. Where we can place the custom tag?
Custom tags can be stored in any of the following locations. ColdFusion will search for them in the order listed.
In the same directory as the calling page - while this is easy for demonstration purposes, it's not very practical, as it means that the custom tag is only available within that directory.
In a directory (or subdirectory of a directory) specified in ColdFusion Administrator under Extensions -> Custom Tag Paths.
In the cfusion/CustomTags directory or one of its subdirectories.
40. What are the different ways to call custom tag?
using cf_ filename of custom tag
using cfmodule tag
using cfimport tag
41. What is CFInclude?
Cfinclude is like substituting a block of code in the page where you are putting the cfinclude tag. The variables in the called page will have the same scope as in the calling page.
42. What is CFModule?
Cfmodule is really a custom tag call. It is, in fact, a way to call a custom tag without needing to place it in the "customtags" folder, or in the same folder as the calling process.
44. What is the difference between Custom tag and Coldfusion Component?
Custom tags have a single entry point; CFCs can have multiple entry points. This makes it possible to create a single component that does many related actions. (To do that with custom tags you'd need multiple tags or cumbersome switch processing.)
Custom tags have no formalized parameter passing and validation mechanism; CFCs do. In other words, unlike custom tags, CFCs can validate passed data, enforce data types, check for required parameters, and optionally assign default values.
Custom tags cannot persist; CFCs can. Custom tags are blocks of code that are executed as is, while CFCs are objects and can be treated as such.
Custom tags are designed to contain code; CFCs are designed to contain both code and data.
Custom tags are accessible only by ColdFusion and only locally; CFCs can be accessed as web services, opening up a whole new world of reuse possibilities.
45. What is CFX tag? What is the use?
The CFX interface is the original ColdFusion extensibility interface. It is fast and powerful, and allows for tags to be written in Java or in C/C++. CFX tags are executables that must be registered in the ColdFusion Administrator so as to bind an alias with the name of the actual executable. Using the CFX interface, it is possible to write extensions that cannot be written using other interfaces.
46. What is Coldfusion component?
ColdFusion Components are essential building blocks used in creating tiered, structured, and scalable applications. Unlike Custom Tags, which are primarily used to encapsulate processing, and UI abstractions, ColdFusion Components are designed to black-box processing, transactions, back-end integration, and the like.
48. How can you invoke CFC?
Method 1:
view plaincopy to clipboardprint?
1. <cfinvoke>
2. <cfinvoke component="user" method="Get" returnvariable="usr">
3. <cfinvokeargument name="id" value="#id#">
4. </cfinvoke>
Method 2:
view plaincopy to clipboardprint?
1. <!--- Load CFC as an object --->
2. <cfobject component="user" name="userObj">
3. <!--- Invoke method --->
4. <cfinvoke component="#userObj#" method="Get" id="#id#" returnvariable="usr">
Method 3:
view plaincopy to clipboardprint?
1. <cfscript>
2. // Load CFC as an object
3. userObj=CreateObject("component", "user");
4. // Invoke method
5. user_id=userObj.Get(id);
6. </cfscript>
Method 4: URL Invocation
CFCs can also be invoked on the command line directly; every CFC has a URL that points to it. When invoking CFCs via URLs, the method and any arguments are passed as URL parameters, as seen here:
http://localhost/users/user.cfc?method=get&id=1

50. What are the different ways to access CFC?
Same as 48
51. What is CFobject?
CFC can be instantiated as an object, using the <cfobject> tag.
52. What is CreateObject?
CreateObject() is a functional equivalent of the <cfobject> tag. CreateObject() can be used to instantiate CFCs just like <cfobject> can, but there is one notable difference: As a function, CreateObject() can be used in a <cfscript> block (whereas <cfobject> cannot).
56. How can you call the external exe files?
using cfexecute tag, we can call the external exe files.Below example executes the Windows NT version of the netstat network monitoring program, and places its output in a file.
<cfexecute name = "C:\WinNT\System32\netstat.exe"
arguments = "-e"
outputFile = "C:\Temp\output.txt"
timeout = "1">
</cfexecute>
57. What is cfexecute? What are the attributes? What is the drawback of using this?
CFExecute is a tag used to execute developer-specified process on server computer. It has some restrictions like; it cannot run in windows 2003 and cannot run a batch file.
Attribute Description
name Absolute path of the application to execute. On Windows, you must specify an extension, for example, C:\myapp.exe.
arguments Command-line variables passed to application. If specified as string, it is processed as follows:
* Windows: passed to process control subsystem for parsing.
* UNIX: tokenized into an array of arguments. The default token separator is a space; you can delimit arguments that have embedded spaces with double-quotation marks.
If passed as array, it is processed as follows:
* Windows: elements are concatenated into a string of tokens, separated by spaces. Passed to process control subsystem for parsing.
* UNIX: elements are copied into an array of exec() arguments.
outputFile File to which to direct program output. If no outputfile or variable attribute is specified, output is displayed on the page from which it was called.
If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.
timeout Length of time, in seconds, that ColdFusion waits for output from the spawned program.
* 0: equivalent to nonblocking mode.
* A very high value: equivalent to blocking mode.
If the value is 0:
* ColdFusion starts a process and returns immediately. ColdFusion may return control to the calling page before any program output displays. To ensure that program output displays, set the value to 2 or higher.
* If the outputFile attribute is not specified, any program output is discarded
variable Variable in which to put program output. If no outputfile or variable attribute is specified, output is displayed on page from which it was called.
58. What is WDDX? Where all are applicable?
For XML to work, both sender and recipient must agree on an XML language, and all data must be well formed according to that language. WDDX is Macromedia's contribution to the XML community. It is an open-source XML DTD (Document Type Definition) that defines generic data types such as strings, arrays, structures, and recordsets. WDDX is an XML language that defines data not any specific implementation, but raw data itself. This can make data sharing via XML quick and painless (it doesn't require that an XML language be agreed upon).
69. What is CFScheduler?
It provides a programmatic interface to the ColdFusion scheduling engine. It can run a CFML page at scheduled intervals, with the option to write the page output to a static HTML page. This feature enables you to schedule pages that publish data, such as reports, without waiting while a database transaction is performed to populate the page.
77. What is CFTransaction?
For enterprise database management systems that support transaction processing, instructs the database management system to treat multiple database operations as a single transaction. It provides database commit and rollback processing. See the documentation for your database management system to determine whether it supports SQL transaction processing.
Syntax
view plaincopy to clipboardprint?
1. <cftransaction
2. action = "begin|commit|rollback|setsavepoint"
3. isolation = "read_uncommitted|read_committed|repeatable_read"
4. savepoint = "savepoint name">
5. </cftransaction>
78. Can we have more than Data Source within CFTransaction?
No.Datasource Names For All The Database Tags Within CFTRANSACTION Must Be The Same.
The workaround for the problem of CFTRANSACTION with different data source,
Use same datasource in CFQUERY
but inside the cfquery prefix the table with desired database in the query.
<CFTRANSACTION>
<cfquery datasource=same>
SELECT * FROM TableName
</cfquery>
<cfquery datasource=same>
SELECT * FROM other.dbo.TableName
</cfquery>
</CFTRANSACTION>
79. What are the different attributes in CFQuery?
Attribute Description
name Name of query. Used in page to reference query record set. Must begin with a letter. Can include letters, numbers, and underscores.
blockFactor Maximum rows to get at a time from server. Range: 1 - 100. Might not be supported by some database systems.
cachedAfter Date value (for example, April 16, 1999, 4-16-99). If date of original query is after this date, ColdFusion uses cached query data. To use cached data, current query must use same SQL statement, data source, query name, user name, password.
A date/time object is in the range 100 AD-9999 AD.
When specifying a date value as a string, you must enclose it in quotation marks.
cachedWithin Timespan, using the CreateTimeSpan function. If original query date falls within the time span, cached query data is used. CreateTimeSpan defines a period from the present, back. Takes effect only if query caching is enabled in the Administrator.
To use cached data, the current query must use the same SQL statement, data source, query name, user name, and password.
dataSource Name of data source from which query gets data. You must specify either dbtype or dataSource.
dbtype Results of a query as input. You must specify either dbtype or dataSource.
debug • yes, or if omitted: if debugging is enabled, but the Administrator Database Activity option is not enabled, displays SQL submitted to the data source and number of records returned by query.
• no: if the Administrator Database Activity option is enabled, suppresses display.
maxRows Maximum number of rows to return in record set.
password Overrides the password in the data source setup.
result Name for the structure in which cfquery returns the result variables. For more information, see Usage.
timeout Maximum number of seconds that each action of a query is permitted to execute before returning an error. The cumulative time may exceed this value.
For JDBC statements, ColdFusion sets this attribute. For other drivers, see the driver documentation.
username Overrides user name in the data source setup.

80. What is Query in Query?
ColdFusion allows developers to reuse existing queries by running queries against them in memory. This gives you the advantage of being able to avoid the often costly performance hit of going back to the database to manipulate data that the application server has already recently called. A standard <cfquery> statement can be used to call a query variable in memory as though it were simply a table of data in an available data source. Query variables can even be joined, which provides interesting possibilities for joining data from disparate information sources.

85. How can you connect with database from Coldfusion?
Database manipulation tags (cfquery, cfstoredproc, cfinsert, cfupdate) have an attribute called datasource which used to identify/connect to a database.
Data sources can be defined in CF administrator section.
90. How can you create Tab strip?
Coldfusion introduced easy to use AJAX UI elements. cflayout and cflayoutarea tags used to create tab strips.
view plaincopy to clipboardprint?
1. <cflayout type="tab">
2. <cflayoutarea title="Tab 1">
3. I am normal tab content
4. </cflayoutarea>
5. <cflayoutarea title="Tab 2" selected="true">
6. This tab selected at page load
7. </cflayoutarea>
8. <cflayoutarea title="Tab 3" disabled="true">
9. you can't see me, bcz I am in disabled tab
10. </cflayoutarea>
11. <cflayoutarea title="Tab 4" closable="true">
12. U can kill :) (close) me
13. </cflayoutarea>
14. </cflayout>
91. What is Flash form?
Flash form is a form like ordinary HTML form, with flash format which run on flash player enabled browsers.
Using cfform tag CF automatically generates the swf format form's Flash binary from your CFML code.
Flash Forms can be used to create a better forms experience for your users.
These features include accordion-style and multiple-tab form panes and automatic element positioning.
You can also display cftree, cfgrid, and cfcalendar form elements as Flash

92. How can you show the report in PDF?
CF Report builder is professional reporting tool coming with CF. CF 8.0.1 contains build in report builder.
In earlier releases, this report builder available as separate installable. You can find the downloads below URL
http://www.adobe.com/support/coldfusion/downloads_updates.html
There have been many software packages that offer these types of solutions, including Crystal Reports, Actuate
CFReport tag used to integrate the Report builder templates into HTML & Pdf reports. Format attribute of cfreport tag used to show the reports into PDF.

<cfreport template="userList.cfr" query="users" format="PDF" title="Sales Department Employees" />
93. What is SaveContent?
Used to save the generated content to a variable, including the results of evaluating expressions and executing custom tags.
This tag requires an end tag.
Main usage of savcontent is cache partial pages.
94. What is CFFlush?
The first occurrence of this tag on a page sends back the HTML headers and any other available HTML. Subsequent cfflush tags on the page send only the output that was generated after the previous flush.
When you flush data, ensure that enough information is available, as some browsers might not respond if you flush only a small amount. Similarly, set the interval attribute for a few hundred bytes or more, but not thousands of bytes.
Use the interval attribute only when a large amount of output will be sent to the client, such as in a cfloop or a cfoutput of a large query. Using this form globally (such as in the Application.cfm file) might cause unexpected errors when CFML tags that modify HTML headers are executed.
Caution: Because the cfflush tag sends data to the browser when it executes, it has several limitations, including the following: Using any of the following tags or functions on a page anywhere after the cfflush tag can cause errors or unexpected results: cfcontent, cfcookie, cfform, cfheader, cfhtmlhead, cflocation, and SetLocale. (These tags and functions normally modify the HTML header, but cannot do so after a cfflush tag, because the cfflush sends the header.) Using the cfset tag to set a cookie anywhere on a page that has a cfflush tag does not set the cookie in the browser. Using the cfflush tag within the body of several tags, including cfsavecontent, cfquery, and custom tags, cause errors. If you save Client variables as cookies, any client variables that you set after a cfflush tag are not saved in the browser.
Note: Normally, the cferror tag discards the current output buffer and replaces it with the contents of the error page. The cfflush tag discards the current buffer. As a result, the Error.GeneratedContent variable resulting from a cferror tag after a cfflush contains any contents of the output buffer that has not been flushed. This content is not sent to the client. The content of the error page displays to the client after the bytes that have been sent.
95. What is the difference between HTMLEditFormat and HTMLCodeFormat?
Both are used to replaces special characters in a string with their HTML-escaped equivalents
Difference between HTMLCodeFormat function and HTMLEditFormat is that HTMLEditFormat does not surround the text in an HTML pre tag
96. What is URLFormat?

Part A:
This is simply the http path to your server and the directory.
It contains 3 components,
The protocol to use to retrieve the object. (Eg, Http, Https)
DNS name or an IP address Web server
The host machine port on which the Web server is running. If omitted, the specified protocol's default port is used; for Web servers, this port is 80.
Part B:
This is the name of application or file to retrieve or the script to execute
Part C:
This is the most important part of the URL also known as the query string.
It is started by the question mark "?".
Individual parameters, are separated by the ampersand "&".
97. What is CFAbort?
Stops the processing of a ColdFusion page at the tag location.
ColdFusion returns to the user or calling tag everything that was processed before the cfabort tag.
You can optionally specify an error message to display using showError attribute.
The tag is often used with conditional logic to stop processing a page when a condition occurs.
98. What is the difference between CFAbort and CFBreak?
Please see Answer:101
99. What is CFQueryparam? What is the use?
It separates parameters from the surrounding SQL.
It allows the database’s SQL analyzer to more efficiently handle the SQL statement
It validates data for the parameters which used to avoid SQL injection attacks.
One limitation of cfqueryparam in earlier versions.
you can’t use the cachedwithin or cachedafter attributes of the cfquery tag when using the cfqueryparam tag.
CF 8 will allow this
100. How can you create dynamic query?
Dynamic SQL is a SQL code that your program generates using variables before the SQL is executed.
In coldfusion, CFQUERY give full provision to write all conditional logic & looping to derive the dynamic sql statement to execute.
You can use dynamic SQL to accomplish tasks such as adding WHERE clauses to a search based on the fields that the user filled out on a search criteria page.
101. What is the difference between cfabort, cfexit, cfbreak
Cfbreak:
* Used within a cfloop/cfswitch tag used to break out of a loop/switch block.
Cfabort:
* Stops the processing of a ColdFusion page at the tag location.
Cfexit:
* cfexit returns control to the page that called that custom tag, or in the case of a tag called by another tag, to the calling tag.
* If cfexit is used outside a custom tag, it functions like a cfabort.
102. What is the difference between cfset, cfparam?
CFparm only writes to the variable if the variable does not exist.
CFSet overwrites the variable with a new value regardless of if it exists.
103. How can you implement cfparam into cfscript?
Tag Version:
<cfparam name="variableName" default="defaultValue">
Script Version:
<cfscript>
if(Not isDefined('variableName'))
variableName = "defaultValue"
</cfscript>
104. What is the use of cfcookie expires attribute? What is the default value for the same?
It defines lifetime or scope of a cookie variable.
expires attribute is optional attribute for cfcookie tag.Default value is till the browser is closed.If you didn't mention the expires attribute for an cookie variable it will available upto browser close.
105. What is the difference between cfquery & cfinsert/cfupdate
CfQuery
* Safer for SQL injection attack
* Can do any sql operations
Cfinsert/Cfupdate
* Designed to do one thing and one thing only
* Only work with FORM fields
* FORM fields be named the same as the table columns
* Cannot do any processing or manipulation of the values
* When updating the row primary key must be present as a FORM field (possibly as a hidden field).
* If you are using CFCs as a database abstraction layer then you can't use cfinsert/cfupdate
106. cfquery/cfstoredproc Which is good for stored proc call?
To execute a stored procedure, you can use either the <cfquery> or <cfstoredproc> tag. Each has its own advantages and disadvantages.
cfquery :
* simple to use
* Maximum flexibility in terms of creating dynamic sql for the query
cfstoredproc :
* It provides support for multiple record sets returned from a stored procedure, meaning that you can create more than one record set from the same procedure.
* Some variables, such as the status code that is created when the tag is called, are not available through cfquery.
107.What is the use of cfsetting?
This tag used to Control the requested URL's page processing, such as the output of HTML code in pages.It has 3 attributes.
* enableCFoutputOnly
* requestTimeOut
* showDebugOutput
All are optional attributes. you should mention atleast one attribute.Here I will explain a bit about requestTimeOut attribute.Rest two explained for the next question.
This attribute added in ColdFusion MX varsion.
It used to define time limit, after which ColdFusion processes the page as an unresponsive thread.
Overrides the time-out set in the ColdFusion Administrator.
108. Explain about enableCFoutputOnly, showDebugOutput attributes of cfsetting tag
enableCFoutputOnly
* yes: blocks output of HTML that is outside cfoutput tags.
* no: displays HTML that is outside cfoutput tags.
showDebugOutput
* yes: if debugging is enabled in the Administrator, displays debugging information.
* no: suppresses debugging information that would otherwise display at the end of the generated page.

Source: http://cfmitrah.com/blog/post.cfm/coldfusion-interview-questions-with-answers-part-3
PRchecker.info

Thursday, January 28, 2010

COLDFUSION TECHNICAL INTERVIEW QUESTIONS

COLDFUSION TECHNICAL INTERVIEW QUESTIONS:

1. Difference between HTMLEditFormat function and HTMLCodeFormat?

The only difference between HTMLEditFormat function and HTMLCodeFormat is that HTMLCodeFormat surrounds the text in an HTML pre tag.

2. what happens when we sent request to coldfusion page ?
Let us say we sent request to hello.cfm page, coldfusion server will generate .class file in the format of "cfhello2ecfm1644549835.class"
we can check the generated .class file under the folder "C:\ColdFusion8\wwwroot\WEB-INF\cfclasses"

3. How can we apply alternate colors for table row while rendering a table ?
Using mod function we can segregate even/odd rows and can apply colors to table rows accordingly.

4. What will happen if we use cfsettings enableDebugOutput value set to "yes" before cfdocument tag
It will throw an error with the message similar to "cfdocument tag has no body. "

5. Can we use multiple datasources inside cftransaction tag?
No. If we use multiple datasources inside cftransaction we will get following error
Datasource names for all the database tags within the cftransaction tag must be the same.

6. How you access stored procedures in ColdFusion?

Using tag:  cfstoredproc datasource="dsn" name="storedproc_name"

7. Benefits of storedprocedure?
1. Faster in execution as queries are pre-compiled and optimized.
2. Can achieve type safety as IN/OUT parameters and their datatypes are strictly defined.
3. For better security as SQL injection and manipulation hacks are virtually eliminated.
4. Will get multiple result sets through single round trip to database server.
5. Has the functionality to call one procedure in another to achieve powerful layer of business logic.

 
Please contact me at raghuramgreddy@gmail.com or make a comment here.

PRchecker.info