<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8244039807493704520</id><updated>2011-11-27T17:36:50.853-08:00</updated><category term='VBScript'/><category term='select case'/><category term='JSP'/><category term='SQL'/><category term='sql server case'/><category term='Java Interview Questions'/><category term='Stored Procedures'/><category term='select case sql'/><category term='sql case statement'/><category term='SQL Interview Questions'/><category term='LEFT JOIN'/><category term='OUTER JOIN'/><category term='LDAP'/><category term='ASP.NET'/><category term='case in sql'/><category term='EJB'/><category term='SQL INDEXING'/><category term='INNER JOIN'/><category term='ASP.NET interview Questions'/><category term='Sealed Class'/><category term='ACTIVE DIRECTORY'/><category term='sql case when'/><category term='Technical Questions'/><category term='C#.Net'/><category term='Web Applications'/><category term='SQL Views'/><category term='SQL Date Search'/><title type='text'>Byte Your Head</title><subtitle type='html'>ASP.NET Tutorials, JAVA, EJB and SQL Server Related Queries and Other Technical Related Stuffs &amp;amp; Useful interview questions</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-9033079067768014229</id><published>2009-06-24T20:55:00.000-07:00</published><updated>2009-06-24T20:55:43.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Sealed Class'/><title type='text'>SEALED CLASS in .NET</title><content type='html'>The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What is a sealed class?&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;It is a class, which cannot be subclassed. it is a good practice to mark your classes as sealed, if you do not intend them to be subclassed.&lt;br /&gt;&lt;br /&gt;The two primary uses of the sealed keyword are as they apply to the class and as they are applied to elements of the class.You might also apply the sealed keyword to virtual functions that you are overriding in a child class.&amp;nbsp; This has the effect of allowing you to prevent the virtual function from being overridden in the child class past the class where it has been sealed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: green; font-size: x-small;"&gt;// Sealed class&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;sealed&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;class&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; SealedClass&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In the following code, I create a sealed class &lt;strong&gt;SealedClass&lt;/strong&gt; and use it from Class1. If you run this code, it will work fine. But if you try to derive a class from sealed class, you will get an error.&amp;nbsp; &lt;br /&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&lt;br /&gt;using&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;class&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; Class1&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;void&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; Main(&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;string&lt;/span&gt;&lt;span style="font-size: x-small;"&gt;[] args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SealedClass sealedCls = &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;new&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; SealedClass();&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; total = sealedCls.Add(4, 5);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Total = " + total.ToString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: green; font-size: x-small;"&gt;// Sealed class&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;sealed&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;class&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; SealedClass&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;int&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; Add(&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;int&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; x, &lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;int&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; y)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue; font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style="font-size: x-small;"&gt; x + y;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;In C# a method can't be declared as sealed. However when we override a method in a derived class, we can declare the overrided method as sealed as shown below. By declaring it as sealed, we can avoid further overriding of this method.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span&gt;using System;&lt;br /&gt;class MyClass1 &lt;br /&gt;{&lt;br /&gt;   public int x; &lt;br /&gt;   public int y;&lt;br /&gt;&lt;br /&gt;   public virtual void Method()&lt;br /&gt;   {&lt;br /&gt; Console.WriteLine("virtual method");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class MyClass : MyClass1&lt;br /&gt;{&lt;br /&gt;   public override sealed void Method()&lt;br /&gt;   {&lt;br /&gt; Console.WriteLine("sealed method");&lt;br /&gt;   } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class MainClass &lt;br /&gt;{&lt;br /&gt;   public static void Main() &lt;br /&gt;   {&lt;br /&gt;      MyClass1 mC = new MyClass(); &lt;br /&gt;      mC.x = 110;&lt;br /&gt;      mC.y = 150;&lt;br /&gt;      Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y); &lt;br /&gt;      mC.Method();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-9033079067768014229?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/9033079067768014229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/sealed-class-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/9033079067768014229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/9033079067768014229'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/sealed-class-in-net.html' title='SEALED CLASS in .NET'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-6484275447834580332</id><published>2009-06-23T19:55:00.000-07:00</published><updated>2009-07-06T03:52:18.451-07:00</updated><title type='text'>Basic ASP.NET Interview Questions - Part 2</title><content type='html'>&lt;div style="text-align: justify;"&gt;1.What attribute do you use to hide a public .NET class from COM? &lt;br /&gt;Use the ComVisible attribute to select which public .NET classes and members are visible to COM. This attribute applies hierarchically for the assembly, class, and member levels.&lt;br /&gt;&lt;br /&gt;2.Why can’t you open a new browser window using server-side code? How would you display a page in a new window with a client-side script? &lt;br /&gt;Server-side code can execute tasks only on the server. To perform a task on the client’s computer, such as opening a new browser window, the code needs to run on the client.&lt;br /&gt;&lt;br /&gt;3.How do you declare an unmanaged procedure within .NET? &lt;br /&gt;Use the DllImport attribute or a Visual Basic .NET Declare statement to declare an unmanaged procedure for use with a .NET assembly. The DllImport attribute is found in the System.Runtime.InteropServices namespace.&lt;br /&gt;&lt;br /&gt;4.Which ASP.NET authentication mode is best suited to identifying and authorizing users who belong to a corporate network? &lt;br /&gt;Windows authentication is best suited to authenticating users of a corporate network because it uses the accounts and permissions that already exist for network users.&lt;br /&gt;&lt;br /&gt;5.What is the difference between Windows and Forms authentication user lists in Web.config? &lt;br /&gt;User lists for Windows authentication are included in the &lt;/div&gt;&lt;authorization&gt;&lt;div style="text-align: justify;"&gt; element of Web.config. User lists for Forms authentications are included in the &lt;/div&gt;&lt;credentials&gt;&lt;div style="text-align: justify;"&gt; element of Web.config or as part of an external users database or file.&lt;br /&gt;&lt;br /&gt;6.How does the Secure Sockets Layer (SSL) provide security in a Web application? &lt;br /&gt;SSL protects data exchanged between a client and a Web application by encrypting the data before it is sent across the Internet.&lt;br /&gt;&lt;br /&gt;7.What permissions do Web applications run under by default? &lt;br /&gt;By default, Web applications run as the ASPNET user, which has limited permissions equivalent to the Users group.&lt;br /&gt;&lt;br /&gt;8.Why is the Machine.config file important to deployed Web applications? &lt;br /&gt;The Machine.config file controls many aspects of how Web applications run, including how processes are recycled, what types of request queue limits are imposed, and what interval is used when checking if users are still connected.&lt;br /&gt;&lt;br /&gt;9.How do you configure a setup project to install an application over the Web? &lt;br /&gt;To configure a setup project to install an application over the Web, select the Web Bootstrapper option from the setup project’s properties. This setting allows the Windows Installer to be downloaded and installed over the Web.&lt;br /&gt;&lt;br /&gt;10.How do you distribute shared components as part of an installation program? &lt;br /&gt;Shared components should be included as a merge module within the setup project. Merge modules manage the installation of shared components so that they’re not unnecessarily overwritten and so that they can be safely removed when no longer used. Unlike regular setup projects, merge modules can’t be installed by themselves—they can be installed only as part of an application installation.&lt;br /&gt;&lt;br /&gt;11.How does deploying to a Web farm or a Web garden affect Session state in a Web application? &lt;br /&gt;Web applications that are deployed to a Web farm or a Web garden need to identify a Session state provider in their Web.config file. This is because a single client’s requests can be directed to different processes over the course of his or her session. The Session state provider allows each different process to access the client’s Session state.&lt;br /&gt;&lt;br /&gt;12.How do unit, integration, and regression testing relate to each other? &lt;br /&gt;Unit testing is the foundation that ensures that each piece of code works correctly. Integration testing extends this concept by verifying that pieces work together without errors. Regression tests are made up of the existing unit and integration tests, which are run on a regular schedule to assure that new code did not break previously working code.&lt;br /&gt;&lt;br /&gt;13.Why is load testing likely to be more important for a Web application than for a stand-alone Windows application? &lt;br /&gt;Because Web applications can be public on the Internet, they can have hundreds, thousands, or even millions of users. Load tests let you simulate the expected demand to locate resource conflicts, performance bottlenecks, and other problems that aren’t apparent in single-user tests.&lt;br /&gt;&lt;br /&gt;14.What is the difference between the Debug and Trace classes? &lt;br /&gt;Under the default environment settings, code using the Debug class is stripped out of release builds, while code using the Trace class is left in. The classes are otherwise equivalent.&lt;br /&gt;&lt;br /&gt;15.What are the two special steps you need to take to ensure that a COM component can use a component from a .NET assembly? &lt;br /&gt;To use a .NET component from a COM tool, such as VBScript, you must: &lt;br /&gt;•Register the .NET assembly in the system registry using RegAsm.exe.&lt;br /&gt;•Make sure that the COM component can find the .NET assembly, either by placing the .NET assembly in the global assembly cache, by placing the two components in the same folder, or by following the other assembly-probing rules.&lt;br /&gt;&lt;br /&gt;16.When do you generally create a web user control? &lt;br /&gt;You generally create a web user control when you want to create a group of controls that can be reused throughout a project to perform some logical unit of work.&lt;br /&gt;&lt;br /&gt;17.When do you generally create a custom control ? &lt;br /&gt;You generally create a custom control when you want to combine one or more existing controls into a compiled assembly that can be easily reused in many different projects.&lt;br /&gt;&lt;br /&gt;18.How is deriving important to creating custom Web controls? &lt;br /&gt;Both composite and rendered custom controls are derived from the WebControl base class. That class provides the methods that you override to create the appearance of the custom control.&lt;br /&gt;&lt;br /&gt;19.What is the most important method to override when you’re creating a composite custom control? &lt;br /&gt;You override the CreateChildControls method to add existing controls to a composite custom control.&lt;br /&gt;&lt;br /&gt;20.How is raising a post-back event in a composite control different from raising a post-back event in a rendered control? &lt;br /&gt;In a composite control, you can use one of the contained controls to raise a post-back event. In a rendered control, you must implement the IPostBackEventHandler interface and write a client-side script to raise a post-back event.&lt;br /&gt;&lt;br /&gt;21.Write a directive to cache responses for a Web form for 30 seconds, storing different cache responses based on the value of the lstNames control. &lt;br /&gt;&lt;%@ OutputCache Duration=”30” VaryByParam=”lstNames” %&gt;&lt;br /&gt;&lt;br /&gt;22.A Web form uses fragment caching to store a frequently used user control. At run time, an Object not found error occurs whenever the page is refreshed. What is a likely cause of the error? &lt;br /&gt;The most likely cause is that the user control is referenced in code after it has been cached. Once cached, a user control’s properties and methods are no longer available.&lt;br /&gt;&lt;br /&gt;23.How can you detect when application data is about to be removed from the cache? &lt;br /&gt;Use the onRemoveCallback delegate.&lt;br /&gt;&lt;br /&gt;24.What is the advantage of using CSS rather than in-line styles for formatting a Web application? &lt;br /&gt;Using CSS allows you to maintain formatting separately from the content of your Web forms, so changes are easier to make and consistency is easier to maintain.&lt;br /&gt;&lt;br /&gt;25.Why would you create a style for a class rather than for an HTML element? &lt;br /&gt;You create style classes when you want to apply the same formatting to different types of elements within an application. For example, you might want to create an emphasis style class that applies the same formatting to any text, control, heading, or image that you want to draw the user’s attention to.&lt;br /&gt;&lt;br /&gt;26.How do CSS and XSL relate to each other when it comes to formatting a Web application? &lt;br /&gt;CSS and XSL are complementary techniques for formatting. CSS determines the font, color, size, background, and other appearance aspects of HTML elements on a Web page. XSL is used to transform XML files into HTML output. In this way, XSL controls the position and appearance of items based on their content. Used together, XSL performs the high-level tasks of composition and layout while CSS performs the low-level tasks of applying fonts, colors, and other appearance features&lt;br /&gt;&lt;br /&gt;27.What are the differences between HTML and XML? &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1. In XML, you create your own element names to identify hierarchical nodes of data.&lt;br /&gt;2.XML syntax is much stricter than HTML: elements must always have end-tags, element names are case sensitive, attribute values must always be enclosed in quotation marks, and nested elements must be terminated within their parent elements.&lt;br /&gt;3.XML identifies data conceptually based on the data’s content, rather than based on the type of formatting to apply.&lt;br /&gt;&lt;br /&gt;28.Which HTML attribute does the server control’s ToolTip property map to in the HTML rendered by ASP.NET? &lt;br /&gt;The ToolTip property is rendered as the title attribute at run time.&lt;br /&gt;&lt;br /&gt;29.What is the difference between the CurrentCulture property and the Current­UICulture property? &lt;br /&gt;The CurrentCulture property affects how the .NET Framework handles dates, currencies, sorting, and formatting issues. The CurrentUICulture property determines which satellite assembly is used when loading resources.&lt;br /&gt;&lt;br /&gt;30.How do you detect the user’s culture? &lt;br /&gt;Use the Request object’s UserLanguages array. The value at element 0 corresponds to one of the culture codes used by the CultureInfo class. For example: SLang = Request.UserLanguages(0) &lt;br /&gt;SLang = Request.UserLanguages(0) &lt;br /&gt;&lt;br /&gt;31.What is a neutral culture? &lt;br /&gt;Neutral cultures represent general languages without region-specific differences, such as currency. For example, the “es” culture code represents Spanish. &lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;/credentials&gt;&lt;/authorization&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-6484275447834580332?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/6484275447834580332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/basic-aspnet-interview-questions-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/6484275447834580332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/6484275447834580332'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/basic-aspnet-interview-questions-part-2.html' title='Basic ASP.NET Interview Questions - Part 2'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-3615353571363247625</id><published>2009-06-23T19:49:00.000-07:00</published><updated>2009-07-06T03:44:31.378-07:00</updated><title type='text'>Basic ASP.NET Interview Questions - Part 1</title><content type='html'>&lt;div style="text-align: justify;"&gt;1.What is the main difference between an ASP.NET Web application and a traditional Windows application.&lt;br /&gt;ASP.NET Web applications runs under common language runtime using managed code where as Unmanaged Windows application runs under Windows using unmanaged code.&lt;br /&gt;&lt;br /&gt;2.What are the two main parts of the .NET Framework?&lt;br /&gt;The two main parts of the .NET Framework are&lt;br /&gt;1.The common language runtime (CLR).&lt;br /&gt;2.The .NET Framework class library.&lt;br /&gt;&lt;br /&gt;3.When can’t you use ASP.NET to create a Web application?&lt;br /&gt;When you are developing for non–Microsoft Windows Web servers, such as Linux/Apache.&lt;br /&gt;&lt;br /&gt;4.List the four major differences between Web and Windows applications.&lt;br /&gt;•Web forms cannot use the standard Windows controls. Instead, they use server controls, HTML controls, user controls, or custom controls created specially for Web forms.&lt;br /&gt;•Web applications are displayed in a browser. Windows applications display their own windows and have more control over how those windows are displayed.&lt;br /&gt;•Web forms are instantiated on the server, sent to the browser, and destroyed immediately. Windows forms are instantiated, exist for as long as needed, and are destroyed.&lt;br /&gt;•Web applications run on a server and are displayed remotely on clients. Windows applications run on the same machine they are displayed on.&lt;br /&gt;&lt;br /&gt;5.Describe the life cycle of a Web application: When are Web forms instantiated and how long do they exist?&lt;br /&gt;A Web application starts with the first request for a resource within the application’s boundaries. Web forms are instantiated when they are requested. They are processed by the server and are abandoned immediately after the server sends its response to the client. A Web application ends after all client sessions end.&lt;br /&gt;&lt;br /&gt;6.How do you preserve persistent data, such as simple variables, in a Web application?&lt;br /&gt;You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.&lt;br /&gt;&lt;br /&gt;7.How does the .NET Framework organize its classes?&lt;br /&gt;The .NET Framework uses namespaces to organize its classes.&lt;br /&gt;&lt;br /&gt;8.In Visual Basic .NET, what is the difference between a class module and a code module?&lt;br /&gt;Class modules are instantiated at run time to create objects that provide separate storage for variables and properties in each instance. Code modules do not have instances, so any module-level variables they use are shared among calls to the module’s procedures.&lt;br /&gt;&lt;br /&gt;9.In Visual C#, how do you declare a method to make it available without having to first instantiate an object from the class?&lt;br /&gt;To create a method that can be called without instantiating an object, declare that method as static.&lt;br /&gt;&lt;br /&gt;10.How do you call a member of a base class from within a derived class?&lt;br /&gt;To refer to a member of a base class in Visual Basic .NET, use the MyBase keyword. To refer to a member of a base class in Visual C#, use the base keyword.&lt;br /&gt;&lt;br /&gt;11.Where would you save the following data items so that they persist between requests to a Web form?&lt;br /&gt;•A control created at run time&lt;br /&gt;•An object that provides services to all users&lt;br /&gt;•User preferences&lt;br /&gt;•Save controls created at run time in the Page object’s ViewState.&lt;br /&gt;•Save objects that provide services to all users in the Application state.&lt;br /&gt;•Save user preferences in SessionState.&lt;br /&gt;&lt;br /&gt;12.What is the main difference between the Button server control and the Button HTML control?&lt;br /&gt;When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs on the client.&lt;br /&gt;&lt;br /&gt;13.How do you get several RadioButton controls to interoperate on a Web form so that only one of the RadioButton controls can have a value of True/true at any given time?&lt;br /&gt;Set the GroupName property of each RadioButton to the same name.&lt;br /&gt;&lt;br /&gt;14.Why does ASP.NET perform validation on both the client and the server?&lt;br /&gt;Client-side validation helps avoid round-trips to the server. Validating on the client ensures that the data is valid before it is submitted, in most cases. However, because validation might be turned off (or maliciously hacked) on the client, data must be revalidated on the server side. This provides full assurance that the data is valid while avoiding as many round-trips as possible.&lt;br /&gt;&lt;br /&gt;15.What types of validation would you use to verify that a user entered a valid ­customer number?&lt;br /&gt;You would use a RequiredFieldValidator and a RegularExpressionValidator. If you have access to a list of expected customer numbers, you could replace the RegularExpressionValidator with a CustomValidator that checked the list.&lt;br /&gt;&lt;br /&gt;16.Explain the difference between handling transactions at the data set level and at the database level.&lt;br /&gt;Data sets provide implicit transactions, because changes to the data set aren’t made permanent in the database until you call the Update method. To handle transactions in a data set, process the Update method and check for errors. If errors occur during an update, none of the changes from the data set is made in the database. You can try to correct the error and resubmit the update, or you can roll back the changes to the data set using the RejectChanges method.&lt;br /&gt;&lt;br /&gt;Databases provide explicit transactions through the Transaction object. You create a Transaction object from a database connection and then assign that Transaction object to the commands you want to include in the transaction through the command object’s Transaction property. As you perform the commands on the database, you check for errors. If errors occur, you can either try to correct them and resubmit the command, or you can restore the state of the database using the Transaction object’s RollBack method. If no errors occur, you can make the changes permanent by calling the transaction object’s Commit method.&lt;br /&gt;&lt;br /&gt;17.Explain why exception handling is important to a completed application.&lt;br /&gt;When an unhandled exception occurs in an application, the application stops—the user can’t proceed, and any work he or she did immediately prior to the exception is lost. Exception handling provides a way to intercept and correct unusual occurrences that would otherwise cause these problems.&lt;br /&gt;&lt;br /&gt;18.List two different exception-handling approaches in ASP.NET Web applications.&lt;br /&gt;Exceptions can be handled in exception-handling blocks using the Try, Catch, and Finally keywords in Visual Basic .NET or the try, catch, and finally keywords in Visual C#. They can also be handled using Error event procedures at the Global, Application, or Page levels using the Server object’s GetLastError and ClearError methods.&lt;br /&gt;&lt;br /&gt;19.Describe the purpose of error pages and why they are needed.&lt;br /&gt;Because Web applications run over the Internet, some exceptions occur outside the scope of the application. This means that your application can’t respond directly to these exceptions. These types of exceptions are identified by HTTP response codes, which IIS can respond to by displaying custom error pages listed in your application’s Web.config file.&lt;br /&gt;&lt;br /&gt;20.Explain why tracing helps with exception handling.&lt;br /&gt;Tracing allows you to record unusual events while your application is running, without users being aware of it. If an unanticipated exception occurs, your application can write a message to the trace log, which helps you diagnose problems during testing and after deployment.&lt;br /&gt;&lt;br /&gt;21.How do you call a stored procedure? &lt;br /&gt;Create a command object, set the object’s CommandText property to the name of the stored procedure, and set the CommandType property to StoredProcedure. To execute the stored procedure, use the command object’s ExecuteNonQuery, ExcecuteScalar, ExecuteReader, or ExecutelXmlReader method. For example, the following code calls the Ten Most Expensive&lt;br /&gt;&lt;br /&gt;Products stored procedure on the Northwind Traders database: &lt;br /&gt;// Create a connection for NorthWind Trader's database.&lt;br /&gt;SqlConnection connNWind = new SqlConnection("integrated security=SSPI;" +&lt;br /&gt;"data source=(local);initial catalog=Northwind");&lt;br /&gt;// Create a command object to execute.&lt;br /&gt;SqlCommand cmdTopTen = new SqlCommand(connNWind);&lt;br /&gt;cmdTopTen.CommandText = "Ten Most Expensive Products";&lt;br /&gt;// Set the command properties.&lt;br /&gt;cmdTopTen.CommandType = CommandType.StoredProcedure;&lt;br /&gt;// Create a data reader object to get the results.&lt;br /&gt;SqlDataReader drdTopTen;&lt;br /&gt;// Open the connection.&lt;br /&gt;connNWind.Open();&lt;br /&gt;// Excecute the stored procedure.&lt;br /&gt;&lt;/div&gt;drdTopTen = cmdTopTen.ExecuteReader();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-3615353571363247625?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/3615353571363247625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/basic-aspnet-interview-questions-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3615353571363247625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3615353571363247625'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/basic-aspnet-interview-questions-part-1.html' title='Basic ASP.NET Interview Questions - Part 1'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-8255688938123479548</id><published>2009-06-23T19:39:00.000-07:00</published><updated>2009-07-06T04:01:34.664-07:00</updated><title type='text'>C# .NET interview questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;1.Does C# support multiple-inheritance?&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;2.Who is a protected class-level variable available to?&lt;br /&gt;It is available to any sub-class (a class inheriting this class).&lt;br /&gt;&lt;br /&gt;3.Are private class-level variables inherited?&lt;br /&gt;Yes, but they are not accessible.  Although they are not visible or accessible via the class interface, they are inherited.&lt;br /&gt;&lt;br /&gt;4.Describe the accessibility modifier “protected internal”.&lt;br /&gt;It is available to classes that are within the same assembly and derived from the specified base class.&lt;br /&gt;&lt;br /&gt;5.What’s the top .NET class that everything is derived from?&lt;br /&gt;System.Object.&lt;br /&gt;&lt;br /&gt;6.What does the term immutable mean?&lt;br /&gt;The data value may not be changed.  Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.&lt;br /&gt;&lt;br /&gt;7.What’s the difference between System.String and System.Text.StringBuilder classes?&lt;br /&gt;System.String is immutable.  System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.&lt;br /&gt;&lt;br /&gt;8.What’s the advantage of using System.Text.StringBuilder over System.String?&lt;br /&gt;StringBuilder is more efficient in cases where there is a large amount of string manipulation.  Strings are immutable, so each time a string is changed, a new instance in memory is created.&lt;br /&gt;&lt;br /&gt;9.Can you store multiple data types in System.Array?&lt;br /&gt;No.&lt;br /&gt;&lt;br /&gt;10.What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?&lt;br /&gt;The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow copy.  A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.  A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.&lt;br /&gt;&lt;br /&gt;11.How can you sort the elements of the array in descending order?&lt;br /&gt;By calling Sort() and then Reverse() methods.&lt;br /&gt;&lt;br /&gt;12.What’s the .NET collection class that allows an element to be accessed using a unique key?&lt;br /&gt;HashTable.&lt;br /&gt;&lt;br /&gt;13.What class is underneath the SortedList class?&lt;br /&gt;A sorted HashTable.&lt;br /&gt;&lt;br /&gt;14.Will the finally block get executed if an exception has not occurred?­&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;15.What’s the C# syntax to catch any possible exception?&lt;br /&gt;A catch block that catches the exception of type System.Exception.  You can also omit the parameter data type in this case and just write catch {}.&lt;br /&gt;&lt;br /&gt;16.Can multiple catch blocks be executed for a single try statement?&lt;br /&gt;No.  Once the proper catch block processed, control is transferred to the finally block .&lt;br /&gt;&lt;br /&gt;17.Explain the three services model commonly know as a three-tier application.&lt;br /&gt;Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Class Questions&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.What is the syntax to inherit from a class in C#?&lt;br /&gt;Place a colon and then the name of the base class.&lt;br /&gt;Example: class MyNewClass : MyBaseClass&lt;br /&gt;&lt;br /&gt;2.Can you prevent your class from being inherited by another class?&lt;br /&gt;Yes.  The keyword “sealed” will prevent the class from being inherited.&lt;br /&gt;&lt;br /&gt;3.Can you allow a class to be inherited, but prevent the method from being over-ridden?&lt;br /&gt;Yes.  Just leave the class public and make the method sealed.&lt;br /&gt;&lt;br /&gt;4.What’s an abstract class?&lt;br /&gt;A class that cannot be instantiated.  An abstract class is a class that must be inherited and have the methods overridden.  An abstract class is essentially a blueprint for a class without any implementation.&lt;br /&gt;&lt;br /&gt;5.When do you absolutely have to declare a class as abstract?&lt;br /&gt;1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.&lt;br /&gt;2.  When at least one of the methods in the class is abstract.&lt;br /&gt;&lt;br /&gt;6.What is an interface class?&lt;br /&gt;Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.&lt;br /&gt;&lt;br /&gt;7.Why can’t you specify the accessibility modifier for methods inside the interface?&lt;br /&gt;They all must be public, and are therefore public by default.&lt;br /&gt;&lt;br /&gt;8.Can you inherit multiple interfaces?&lt;br /&gt;Yes.  .NET does support multiple interfaces.&lt;br /&gt;&lt;br /&gt;9.What’s the difference between an interface and abstract class?&lt;br /&gt;In an interface class, all methods are abstract - there is no implementation.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers.&lt;br /&gt;&lt;br /&gt;10.What is the difference between a Struct and a Class?&lt;br /&gt;Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval.  Another difference is that structs cannot inherit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Method and Property Questions &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.What’s the implicit name of the parameter that gets passed into the set method/property of a class?&lt;br /&gt;Value.  The data type of the value parameter is defined by whatever data type the property is declared as.&lt;br /&gt;&lt;br /&gt;2.What does the keyword “virtual” declare for a method or property?&lt;br /&gt;The method or property can be overridden.&lt;br /&gt;&lt;br /&gt;3.How is method overriding different from method overloading?&lt;br /&gt;When overriding a method, you change the behavior of the method for the derived class.  Overloading a method simply involves having another method with the same name within the class.&lt;br /&gt;&lt;br /&gt;4.Can you declare an override method to be static if the original method is not static?&lt;br /&gt;No.  The signature of the virtual method must remain the same.  (Note: Only the keyword virtual is changed to keyword override)&lt;br /&gt;&lt;br /&gt;5.What are the different ways a method can be overloaded?&lt;br /&gt;Different parameter data types, different number of parameters, different order of parameters.&lt;br /&gt;&lt;br /&gt;6.If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?&lt;br /&gt;Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Events and Delegates&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.What’s a delegate?&lt;br /&gt;A delegate object encapsulates a reference to a method.&lt;br /&gt;&lt;br /&gt;2.What’s a multicast delegate?&lt;br /&gt;A delegate that has multiple handlers assigned to it.  Each assigned handler (method) is called.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;XML Documentation Questions &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.Is XML case-sensitive?&lt;br /&gt;Yes.&lt;br /&gt;&lt;br /&gt;2.What’s the difference between // comments, /* */ comments and /// comments?&lt;br /&gt;Single-line comments, multi-line comments, and XML documentation comments.&lt;br /&gt;&lt;br /&gt;3.How do you generate documentation from the C# file commented properly with a command-line compiler?&lt;br /&gt;Compile it with the /doc switch.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Debugging and Testing Questions &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.What debugging tools come with the .NET SDK?&lt;br /&gt;1.   CorDBG – command-line debugger.  To use CorDbg, you must compile the original C# file using the /debug switch.&lt;br /&gt;2.   DbgCLR – graphic debugger.  Visual Studio .NET uses the DbgCLR.&lt;br /&gt;&lt;br /&gt;2.What does assert() method do?&lt;br /&gt;In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false.  The program proceeds without any interruption if the condition is true.&lt;br /&gt;&lt;br /&gt;3.What’s the difference between the Debug class and Trace class?&lt;br /&gt;Documentation looks the same.  Use Debug class for debug builds, use Trace class for both debug and release builds.&lt;br /&gt;&lt;br /&gt;4.Why are there five tracing levels in System.Diagnostics.TraceSwitcher?&lt;br /&gt;The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.&lt;br /&gt;&lt;br /&gt;5.Where is the output of TextWriterTraceListener redirected?&lt;br /&gt;To the Console or a text file depending on the parameter passed to the constructor.&lt;br /&gt;&lt;br /&gt;6.How do you debug an ASP.NET Web application?&lt;br /&gt;Attach the aspnet_wp.exe process to the DbgClr debugger.&lt;br /&gt;&lt;br /&gt;7.What are three test cases you should go through in unit testing?&lt;br /&gt;1.       Positive test cases (correct data, correct output).&lt;br /&gt;2.       Negative test cases (broken or missing data, proper handling).&lt;br /&gt;3.       Exception test cases (exceptions are thrown and caught properly).&lt;br /&gt;&lt;br /&gt;8.Can you change the value of a variable while debugging a C# application?&lt;br /&gt;Yes.  If you are debugging via Visual Studio.NET, just go to Immediate window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;ADO.NET and Database Questions &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.What is the role of the DataReader class in ADO.NET connections?&lt;br /&gt;It returns a read-only, forward-only rowset from the data source.  A DataReader provides fast access when a forward-only sequential read is needed.&lt;br /&gt;&lt;br /&gt;2.What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?&lt;br /&gt;SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix.  OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.&lt;br /&gt;&lt;br /&gt;3.What is the wildcard character in SQL?&lt;br /&gt;Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.&lt;br /&gt;&lt;br /&gt;4.Explain ACID rule of thumb for transactions.&lt;br /&gt;A transaction must be:&lt;br /&gt;1.       Atomic - it is one unit of work and does not dependent on previous and following transactions.&lt;br /&gt;2.       Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.&lt;br /&gt;3.       Isolated - no transaction sees the intermediate results of the current transaction).&lt;br /&gt;4.       Durable - the values persist if the data had been committed even if the system crashes right after.&lt;br /&gt;&lt;br /&gt;5.What connections does Microsoft SQL Server support?&lt;br /&gt;Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).&lt;br /&gt;&lt;br /&gt;6.Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?&lt;br /&gt;Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.&lt;br /&gt;&lt;br /&gt;7.What does the Initial Catalog parameter define in the connection string?&lt;br /&gt;The database name to connect to.&lt;br /&gt; &lt;br /&gt;8.What does the Dispose method do with the connection object?&lt;br /&gt;Deletes it from the memory.&lt;br /&gt;To Do: answer better.  The current answer is not entirely correct.&lt;br /&gt;&lt;br /&gt;9.What is a pre-requisite for connection pooling?&lt;br /&gt;Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.  The connection string must be identical.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Assembly Questions &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.How is the DLL Hell problem solved in .NET?&lt;br /&gt;Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.&lt;br /&gt;&lt;br /&gt;2.What are the ways to deploy an assembly?&lt;br /&gt;An MSI installer, a CAB archive, and XCOPY command.&lt;br /&gt;&lt;br /&gt;3.What is a satellite assembly?&lt;br /&gt;When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.&lt;br /&gt;&lt;br /&gt;4.What namespaces are necessary to create a localized application?&lt;br /&gt;System.Globalization and System.Resources.&lt;br /&gt;&lt;br /&gt;5.What is the smallest unit of execution in .NET?&lt;br /&gt;an Assembly.&lt;br /&gt;&lt;br /&gt;6.When should you call the garbage collector in .NET?&lt;br /&gt;As a good rule, you should not call the garbage collector.  However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory.  However, this is usually not a good practice.&lt;br /&gt;&lt;br /&gt;7.How do you convert a value-type to a reference-type?&lt;br /&gt;Use Boxing.&lt;br /&gt;&lt;br /&gt;8.What happens in memory when you Box and Unbox a value-type?&lt;br /&gt;Boxing converts a value-type to a reference-type, thus storing the object on the heap.  Unboxing converts a reference-type to a value-type, thus storing the value on the stack.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-8255688938123479548?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/8255688938123479548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/c-net-interview-questions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8255688938123479548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8255688938123479548'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/c-net-interview-questions.html' title='C# .NET interview questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-1123643283255014222</id><published>2009-06-22T00:17:00.000-07:00</published><updated>2009-06-22T01:04:08.982-07:00</updated><title type='text'>Servlet Interview Questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;1.What are the uses of Servlets? &lt;/span&gt;&lt;br /&gt;A servlet can handle multiple requests concurrently, and can synchronize requests. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.When doGET() method will going to execute? &lt;/span&gt;&lt;br /&gt;When we specified method=’GET’ in HTML&lt;br /&gt;Example : &lt; name="’SSS’" method="’GET’"&gt;&lt;br /&gt;When doPOST() method will going to execute?&lt;br /&gt;When we specified method=’POST’ in HTML&lt;br /&gt;&lt; name="’SSS’" method="’POST’"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.What is the difference between Difference between doGet() and doPost()? &lt;/span&gt;&lt;br /&gt;GET Method : Using get method we can able to pass 2K data from HTML&lt;br /&gt;All data we are passing to Server will be displayed in URL (request string).&lt;br /&gt;&lt;br /&gt;POST Method : In this method we does not have any size limitation.&lt;br /&gt;All data passed to server will be hidden, User cannot able to see this info&lt;br /&gt;on the browser.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.What is the servlet life cycle? &lt;/span&gt;&lt;br /&gt;When first request came in for the servlet , Server will invoke init() method of the servlet. There after if any user request the servlet program, Server will directly executes the service() method. When Server want to remove the servlet from pool, then it will execute the destroy() method&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.What is the servlet? &lt;/span&gt;&lt;br /&gt;Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.What is the architechture of servlet package? &lt;/span&gt;&lt;br /&gt;Servlet Interface is the central abstraction. All servlets implements this Servlet&lt;br /&gt;Interface either direclty or indirectly&lt;br /&gt;( may implement or extend Servlet Interfaces sub classes or sub interfaces)&lt;br /&gt;&lt;br /&gt;Servlet&lt;br /&gt;|&lt;br /&gt;Generic Servlet&lt;br /&gt;|&lt;br /&gt;HttpServlet ( Class ) — we will extend this class to handle GET / PUT HTTP requests&lt;br /&gt;|&lt;br /&gt;MyServlet&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.What is the difference between HttpServlet and GenericServlet? &lt;/span&gt;&lt;br /&gt;A GenericServlet has a service() method to handle requests.&lt;br /&gt;HttpServlet extends GenericServlet added new methods&lt;br /&gt;doGet()&lt;br /&gt;doPost()&lt;br /&gt;doHead()&lt;br /&gt;doPut()&lt;br /&gt;doOptions()&lt;br /&gt;doDelete()&lt;br /&gt;doTrace() methods&lt;br /&gt;Both these classes are abstract.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.What’s the difference between servlets and applets? &lt;/span&gt;&lt;br /&gt;Servlets executes on Servers. Applets executes on browser. Unlike applets, however, servlets have no graphical user interface.&lt;br /&gt;What is the difference between the getRequestDispatcher(String path) ServletRequest interface and ServletContext interface?&lt;br /&gt;The getRequestDispatcher(String path) method of ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a “/” it is interpreted as relative to the current context root.&lt;br /&gt;&lt;br /&gt;The getRequestDispatcher(String path) method of ServletContext interface cannot accepts relative paths. All path must sart with a “/” and are interpreted as relative to curent context root. If the resource is not available, or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9.What is the use of ServletContext ? &lt;/span&gt;&lt;br /&gt;Using ServletContext, We can access data from its environment. Servlet context is common to all Servlets so all Servlets share the information through ServeltContext.&lt;br /&gt;Is there any way to generate PDF’S dynamically in servlets?&lt;br /&gt;We need to use iText. A open source library for java. Please refer sourceforge site for sample servlet examples.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10.What is the difference between using getSession(true) and getSession(false) methods? &lt;/span&gt;&lt;br /&gt;getSession(true) - This method will check whether already a session is existing for the user. If a session is existing, it will return that session object, Otherwise it will create new session object and return taht object.&lt;br /&gt;&lt;br /&gt;getSession(false) - This method will check existence of session. If session exists, then it returns the reference of that session object, if not, this methods will return null.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11.Which code line must be set before any of the lines that use the PrintWriter? &lt;/span&gt;&lt;br /&gt;setContentType() method must be set.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;12.Which protocol will be used by browser and servlet to communicate ? &lt;/span&gt;&lt;br /&gt;HTTP&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;13.In how many ways we can track the sessions? &lt;/span&gt;&lt;br /&gt;Method 1) By URL rewriting&lt;br /&gt;&lt;br /&gt;Method 2) Using Session object&lt;br /&gt;&lt;br /&gt;Getting Session form HttpServletRequest object&lt;br /&gt;HttpSession session = request.getSession(true);&lt;br /&gt;&lt;br /&gt;Get a Value from the session&lt;br /&gt;session.getValue(session.getId());&lt;br /&gt;&lt;br /&gt;Adding values to session&lt;br /&gt;cart = new Cart();&lt;br /&gt;session.putValue(session.getId(), cart);&lt;br /&gt;&lt;br /&gt;At the end of the session, we can inactivate the session by using the following command&lt;br /&gt;session.invalidate();&lt;br /&gt;&lt;br /&gt;Method 3) Using cookies&lt;br /&gt;&lt;br /&gt;Method 4) Using hidden fields&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;14.How Can You invoke other web resources (or other servlet / jsp ) ? &lt;/span&gt;&lt;br /&gt;Servelt can invoke other Web resources in two ways: indirect and direct.&lt;br /&gt;&lt;br /&gt;Indirect Way : Servlet will return the resultant HTML to the browser which will point to another Servlet (Web resource)&lt;br /&gt;&lt;br /&gt;Direct Way : We can call another Web resource (Servelt / Jsp) from Servelt program itself, by using RequestDispatcher object.&lt;br /&gt;&lt;br /&gt;You can get this object using getRequestDispatcher(”URL”) method. You can get this object from either a request or a Context.&lt;br /&gt;&lt;br /&gt;Example :&lt;br /&gt;RequestDispatcher dispatcher = request.getRequestDispatcher(”/jspsample.jsp”);&lt;br /&gt;if (dispatcher != null)&lt;br /&gt;dispatcher.forward(request, response);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;15.How Can you include other Resources in the Response? &lt;/span&gt;&lt;br /&gt;Using include method of a RequestDispatcher object.&lt;br /&gt;&lt;br /&gt;Included WebComponent (Servlet / Jsp) cannot set headers or call any method (for example, setCookie) that affects the headers of the response.&lt;br /&gt;&lt;br /&gt;Example : RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(”/banner”);&lt;br /&gt;if (dispatcher != null)&lt;br /&gt;dispatcher.include(request, response);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;16.&lt;strong&gt;What is the difference between the getRequestDispatcher(String path)  ServletRequest interface and ServletContext interface?&lt;/strong&gt; &lt;/div&gt;&lt;p style="text-align: justify;"&gt;The getRequestDispatcher(String path) method of ServletRequest interface  accepts parameter the path to the resource to be included or forwarded to, which  can be relative to the request of the calling servlet. If the path begins with a  “/” it is interpreted as relative to the current context root.&lt;/p&gt;&lt;div style="text-align: justify;"&gt; &lt;/div&gt;&lt;p style="text-align: justify;"&gt;The getRequestDispatcher(String path) method of ServletContext interface  cannot accepts relative paths. All path must sart with a “/” and are interpreted  as relative to curent context root. If the resource is not available, or if the  server has not implemented a RequestDispatcher object for that type of resource,  getRequestDispatcher will return null. Your servlet should be prepared to deal  with this condition.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-1123643283255014222?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/1123643283255014222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/servlet-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1123643283255014222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1123643283255014222'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/servlet-interview-questions.html' title='Servlet Interview Questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-9117195213169631498</id><published>2009-06-21T23:56:00.000-07:00</published><updated>2009-06-22T01:04:45.263-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Questions'/><title type='text'>J2EE Interview Questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;1.What do you understand by a J2EE module?&lt;/span&gt;&lt;br /&gt;A J2EE module is a  software unit that consists of one or more J2EE components of the same container  type along with one deployment descriptor of that type. J2EE specification  defines four types of modules:&lt;br /&gt;a) EJB&lt;br /&gt;b) Web&lt;br /&gt;c) application client  and&lt;br /&gt;d) resource adapter&lt;br /&gt;&lt;br /&gt;In the J2EE applications modules can be  deployed as stand-alone units. Modules can also be assembled into J2EE  applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.What are the contents of web module?&lt;/span&gt;&lt;br /&gt;A web module may contain:&lt;br /&gt;a) JSP files&lt;br /&gt;b) Java classes&lt;br /&gt;c) gif and html files and&lt;br /&gt;d) web component deployment descriptors&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.Differentiate between .ear,  .jar and .war files.&lt;/span&gt;&lt;br /&gt;These files are simply zipped file using java jar tool. These files are created for different purposes. Here is the description of these files:&lt;br /&gt;.jar files: These files are with the .jar extenstion. The .jar files contains the libraries, resources and accessories files like property files.&lt;br /&gt;.war files: These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications.&lt;br /&gt;.ear files: The .ear file contains the EJB modules of the application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.What is the difference between Session Bean and Entity Bean? &lt;/span&gt;&lt;br /&gt;Session Bean: Session is one of the EJBs and it represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.&lt;br /&gt;&lt;br /&gt;A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates.&lt;br /&gt;&lt;br /&gt;Entity Bean: An entity bean represents persistent global data from the database. Entity beans data are stored into database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.Why J2EE is suitable for the development distributed multi-tiered enterprise applications?&lt;/span&gt;&lt;br /&gt;The J2EE platform consists of multi-tiered distributed application model. J2EE applications allows the developers to design and implement the business logic into components according to business requirement. J2EE architecture allows the development of multi-tired applications and the developed applications can be installed on different machines depending on the tier in the multi-tiered J2EE environment . The J2EE application parts are:&lt;br /&gt;&lt;br /&gt;a) Client-tier components run on the client machine.&lt;br /&gt;b) Web-tier components run on the J2EE server.&lt;br /&gt;c) Business-tier components run on the J2EE server and the&lt;br /&gt;d) Enterprise information system (EIS)-tier software runs on the EIS servers&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.What are the services provided by a container?&lt;/span&gt;&lt;br /&gt;The services provided by container are as follows:&lt;br /&gt;a) Transaction management for the bean&lt;br /&gt;b) Security for the bean&lt;br /&gt;c) Persistence of the bean&lt;br /&gt;d) Remote access to the bean&lt;br /&gt;e) Lifecycle management of the bean&lt;br /&gt;f) Database-connection pooling&lt;br /&gt;g) Instance pooling for the bean&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.What are types of J2EE clients?&lt;/span&gt;&lt;br /&gt;J2EE clients are the software that access the services components installed on the J2EE container. Following are the J2EE clients:&lt;br /&gt;a) Applets&lt;br /&gt;b) Java-Web Start clients&lt;br /&gt;c) Wireless clients&lt;br /&gt;d) Web applications&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.What do you understand by JTA and JTS?&lt;/span&gt;&lt;br /&gt;JTA stands for Java Transaction API and JTS stands for Java Transaction Service. JTA provides a standard interface which allows the developers to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK uses the JTA transaction manager to implement the  transaction. The code developed by developers does not calls the JTS methods directly, but only invokes the JTA methods. Then JTA internally invokes the JTS routines. JTA is a high level transaction interface used by the application code to control the transaction.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9.What is JAXP?&lt;/span&gt;&lt;br /&gt;The Java API for XML Processing (JAXP) enables applications to parse and transform XML documents independent of a particular XML processing implementation. JAXP or Java API for XML Parsing is an optional API provided by Javasoft. It provides basic functionality for reading, manipulating, and generating XML documents through pure Java APIs. It is a thin and lightweight API that provides a standard way to seamlessly integrate any XML-compliant parser with a Java application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10.What is difference between Java Bean and Enterprise Java Bean?&lt;/span&gt;&lt;br /&gt;Java Bean as is a plain java class with member variables and getter setter methods. Java Beans are defined under JavaBeans specification as Java-Based software component model which includes the features like introspection, customization,  events,  properties and  persistence.&lt;br /&gt;&lt;br /&gt;Enterprise JavaBeans or EJBs for short are Java-based software components that comply with Java’s  EJB specification. EJBs are delpoyed on the EJB container and executes in the EJB container. EJB is not that simple,  it is used for building distributed applications. Examples of EJB are Session Bean, Entity Bean and Message Driven Bean. EJB is used for server side programming whereas java bean is a client side. Bean is only development but the EJB is developed and then deploy on EJB Container.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11.Can Entity Beans have no create() methods?&lt;/span&gt;&lt;br /&gt;Entity Beans can have no create() methods. Entity Beans have no create() method, when entity bean is not used to store the data in the database. In this case entity bean is used to retrieve the data from database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;12.What are the call back methods in Session bean?&lt;/span&gt;&lt;br /&gt;Callback methods are called by the container to notify the important events to the beans in its life cycle.  The callback methods are defined in the javax.ejb.EntityBean interface.The callback methods example are ejbCreate(), ejbPassivate(), and ejbActivate().&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-9117195213169631498?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/9117195213169631498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/j2ee-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/9117195213169631498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/9117195213169631498'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/j2ee-interview-questions.html' title='J2EE Interview Questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-3182060681280824658</id><published>2009-06-21T00:27:00.000-07:00</published><updated>2009-06-21T01:04:03.564-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='JSP'/><title type='text'>JSP interview Questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;1. What is JSP?&lt;/span&gt;&lt;br /&gt;JSP Stands for Java server pages. JSP is Java technology which is used by developers across the world to create dynamically generated websites with the easy use of other documents like HTML, XML. This technology of java allows developers to include java code and some pre defined actions into static content. Java server pages are compiled into java servlet by the java compiler or the java compiler may directly generate the byte code for the servlet.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. How servlet differ from JSP?&lt;/span&gt;&lt;br /&gt;Both Servlet and Java Server Pages are API which generate dynamic web content. A servlet is nothing but a java class which implements the interface to run within a web and on the other hand Java server pages is a bit complicated thing which contain a mixture of Java scripts, Java directives, Java elements and HTML.  The main difference among both servlet and Java server pages is that JSP is document oriented and servlet on the other hand act likes a program.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. What are the advantages of JSP?&lt;/span&gt;&lt;br /&gt;There are many advantages of JSP and JSP is very much preferred by every coder. The main advantage of JSP over anything is its auto compilation and the length of code is reduced by using custom tags and tag library. Secondly, it is portable that is it works on all operating system and non – Microsoft web servers. Java components can be easily embedded into the dynamic pages. JSP have all the features of java and can easily separate dynamic part from the static part of the page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. What are the implicit objects in JSP?&lt;/span&gt;&lt;br /&gt;There are all total 9 implicit objects in JSP. Application interface refers to the web application’s interface whereas Session interface refers to the user’s session. Request interface refers to the page which is currently requested whereas Response interface refers to the response which is currently made by the user. Config interface refers to the servlet configuration. Class like out, page, page Context and exception refers to the output stream of the page, servlet instance of the page, environment of the page, error handling respectively.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. How JSP calls a stored procedure?&lt;/span&gt;&lt;br /&gt;Java Server Pages possess all the characteristics of java and to call and have similar syntax to call a function. Functions and stored procedures of a database can be called by using the statement callable. Another way to call the stored procedure is by writing the JDBC code in between the tag of scriptlet tab.write.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.What are the lifecycle phases of a JSP?&lt;/span&gt;&lt;br /&gt;JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP engine does the following 7 phases.&lt;br /&gt;&lt;br /&gt;1.Page translation: -page is parsed, and a java file which is a servlet is     created.&lt;br /&gt;2.Page compilation: page is compiled into a class file&lt;br /&gt;3.Page loading : This class file is loaded.&lt;br /&gt;4.Create an instance :- Instance of servlet is created&lt;br /&gt;5.jspInit() method is called&lt;br /&gt;6._jspService is called to handle service calls&lt;br /&gt;7._jspDestroy is called to destroy it when the servlet is not required.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.Why are JSP pages the preferred API for creating a web-based client program?&lt;/span&gt;&lt;br /&gt;Because no plug-ins or security policy files are needed on the client systems(applet does). Also, JSP pages enable cleaner and more module application design because they provide a way to separate applications programming from web page design. This means personnel involved in web page design do not need to understand Java programming language syntax to do their jobs.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.Is JSP technology extensible?&lt;/span&gt;&lt;br /&gt;Yes, it is. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9.How does JSP handle run-time exceptions?&lt;/span&gt;&lt;br /&gt;You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. For example: &lt;%@ page errorPage="error.jsp" %&gt;redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive: &lt;%@ page isErrorPage="true" %&gt; Throwable object describing the exception may be accessed within the error page via the exception implicit object. Note: You must always use a relative URL as the value for the errorPage attribute.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10. How do we use a scriptlet to initialize a newly instantiated bean? &lt;/span&gt;&lt;br /&gt;A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically invoked when the specified bean is instantiated. Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the newly instantiated bean, although you are not restricted to using those alone.&lt;br /&gt;The following example shows the “today” property of the Foo bean initialized to the current date when it is instantiated. Note that here, we make use of a JSP expression within the jsp:setProperty action.&lt;br /&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;jsp:setproperty name="foo" property="today" value=""&gt;"&gt;&lt;/jsp:setproperty&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;jsp:setproperty name="foo" property="today" value=""&gt;"&gt;&lt;%-- scriptlets calling bean setter methods go here --%&gt;&lt;/jsp:setproperty&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;jsp:setproperty name="foo" property="today" value=""&gt;"&gt;&lt;/jsp:setproperty&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;/jsp:usebean&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/jsp:usebean&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;span style="font-weight: bold;"&gt;11.What are custom tags and why it is needed? &lt;/span&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;JSP tags are extended by creating a custom set of tags which is called as tag library (taglib). The page which uses custom tags declares taglib and uniquely names, defines and associates a tag prefix to differentiate the usage of those tags.&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;span style="font-weight: bold;"&gt;12.How cookies is deleted in JSP?&lt;/span&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;There are two ways by which the cookies can be deleted in JSP. Firstly, by setting the setMaxAge() of the cookie class to zero. And secondly by setting a timer in the header file that is response. setHeader(expires {Mention the time} attribute), which will delete the cookies after that prescribed time.&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;span style="font-weight: bold;"&gt;13.Is it possible by a JSP page to process HTML form data?&lt;/span&gt;&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;Yes ,it is possible by simply obtaining the data from the FORM input via the request implicit object which lies with a scriptlet or expression but it doesn't require to implement any HTTP – Protocol methods like goGet() or doPost() within the JSP page.&lt;/jsp:usebean&gt;&lt;br /&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;/jsp:usebean&gt;&lt;/div&gt;&lt;jsp:usebean id="foo" class="com.Bar.Foo"&gt;&lt;br /&gt;&lt;/jsp:usebean&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-3182060681280824658?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/3182060681280824658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/jsp-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3182060681280824658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3182060681280824658'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/jsp-interview-questions.html' title='JSP interview Questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-320599103677526757</id><published>2009-06-19T20:49:00.000-07:00</published><updated>2009-06-19T21:30:28.638-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LDAP'/><category scheme='http://www.blogger.com/atom/ns#' term='VBScript'/><category scheme='http://www.blogger.com/atom/ns#' term='ACTIVE DIRECTORY'/><title type='text'>LDAP And ACTIVE DIRECTORY</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;What is LDAP?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;LDAP, Lightweight Directory Access Protocol, is an Internet protocol that email and other programs use to look up information from a server.&lt;br /&gt;&lt;br /&gt;This is an application protocol for querying and modifying directory services running over TCP/IP.&lt;br /&gt;&lt;br /&gt;Key aspects of LDAP are:&lt;br /&gt;&lt;br /&gt; - Protocol elements are carried directly over TCP or other transport,&lt;br /&gt;   bypassing much of the session/presentation overhead.&lt;br /&gt;&lt;br /&gt; - Many protocol data elements are encoding as ordinary strings (e.g.,&lt;br /&gt;   Distinguished Names).&lt;br /&gt;&lt;br /&gt; - A lightweight BER encoding is used to encode all protocol elements.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What is Active Directory?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An active directory is a directory structure used on Microsoft Windows based computers and servers to store information and data about networks and domains. It is primarily used for online information and was originally created in 1996 and first used with Windows 2000.&lt;br /&gt;&lt;br /&gt;An active directory (sometimes referred to as an AD) does a variety of functions including the ability to provide information on objects, helps organize these objects for easy retrieval and access, allows access by end users and administrators and allows the administrator to set security up for the directory.&lt;br /&gt;&lt;br /&gt;An active directory can be defined as a hierarchical structure and this structure is usually broken up into three main categories, the resources which might include hardware such as printers, services for end users such as web email servers and objects which are the main functions of the domain and network.&lt;br /&gt;&lt;br /&gt;If you are a computer administrator for a large corporation or organization, you can easily update all end users computers with new software, patches, files, etc simply by updating one object in a forest or tree.&lt;br /&gt;&lt;br /&gt;Access to information stored in Active Directory is available using standard Active Directory management utilities. They are convenient and fairly easy to use; however, there are situations in which you might want to develop alternative, custom solutions. For example, you might want to quickly access user or group account information from any workstation in your environment.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Technical Details To Access Active Directory via ASP (vb script)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The script below, ListADGroups.vbs, uses Active Data Objects (and an underlying OLE DB Directory Services provider called ADsDSOObject) to extract a list of groups from Active Directory. This involves creating the following ADO objects:&lt;br /&gt;&lt;br /&gt;  * A Connection object stored in oCon variable,&lt;br /&gt;  * A Command object stored in oCmd variable,&lt;br /&gt;  * A RecordSet object, stored in oRecordSet variable.&lt;br /&gt;&lt;br /&gt;For each of these objects, we set appropriate properties. More specifically, for the Connection object:&lt;br /&gt;&lt;br /&gt;  * Provider property determines OLE DB provider used for connection to Active Directory (ADSDSOObject)&lt;br /&gt;  * sUser variable is the name of the domain user that will be used to connect to Active Directory (replace this value with an actual user name in your domain)&lt;br /&gt;  * sPassword variable is a password for the sUser account (set it appropriately as well)&lt;br /&gt;&lt;br /&gt;For the Command Object:&lt;br /&gt;&lt;br /&gt;  * ActiveConnection property is set to the previously created oCon object&lt;br /&gt;  * CommandText property consists of semicolon-separated search parameters. The scope is determined by the first parameter, which contains, in this case, the LDAP path of the target domain. The second parameter contains search criteria. objectCategory determines the type of object to search for (groups in our case). The objects are filtered according to the value of the sGroup variable. For example, in order to return all the groups with names that start with the "US" prefix, you would set sGroup to "US*". The value of "*" used in the script returns all the groups within the scope determined by the first parameter (domain in this case). Object properties to be returned are listed in the third parameter (and include group name, LDAP path, description, and group members). Finally, the last parameter specifies search depth (in the hierarchy of Active Directory containers) -- all directory objects in our case.&lt;br /&gt;&lt;br /&gt;The outcome of running the Execute method of the ADO Command object is stored in the RecordSet. In order to retrieve the results, the script traverses it record by record and displays contents of each one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Check Out the Function to Query The Active Directory using LDAP into a recordset&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sub GetDisplayName()&lt;br /&gt;&lt;br /&gt;  Dim conn&lt;br /&gt;  Dim com&lt;br /&gt;  Dim oRecordset&lt;br /&gt;&lt;br /&gt;  '*******************************&lt;br /&gt;  '*  Open the connection to AD  *&lt;br /&gt;  '*******************************&lt;br /&gt;&lt;br /&gt;  Set conn = CreateObject("ADODB.Connection")&lt;br /&gt;  conn.Provider = "ADsDSOObject"&lt;br /&gt;  conn.Properties("User ID") = "Dir Mgr"&lt;br /&gt;  conn.Properties("Password") = "MyPassword"&lt;br /&gt;&lt;br /&gt;  conn.Open "LDAP Provider"&lt;br /&gt;&lt;br /&gt;  Set com = CreateObject("ADODB.Command")&lt;br /&gt;  com.ActiveConnection = conn&lt;br /&gt;&lt;br /&gt;  com.CommandText = "SELECT  displayName FROM 'LDAP://MyHost:477/OU=abc,DC=ad,DC=mhkk,DC=com'"&lt;br /&gt;&lt;br /&gt;  oRecordset = com.Execute&lt;br /&gt;&lt;br /&gt;end sub&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-320599103677526757?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/320599103677526757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ldap-and-active-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/320599103677526757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/320599103677526757'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ldap-and-active-directory.html' title='LDAP And ACTIVE DIRECTORY'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-5820907691173142098</id><published>2009-06-18T03:41:00.001-07:00</published><updated>2009-06-19T01:48:48.125-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>Delegates and Events in C#.Net</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size:130%;"&gt;Delegates in C# .Net:&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;br /&gt;If we look at C++ there is a feature called callback function. This feature uses Pointers to Functions to pass them as parameters to other functions. Delegate is a similar feature but it is more type safe, which stands as a stark contrast with C++ function pointers. A delegate can hold reference/s to one more more functions and invoke them as and when needed.&lt;br /&gt;&lt;br /&gt;A delegate needs the method's name and its parameters (input and output variables) when we create a delegate. But delegate is not a standalone construction. it's a class. Any delegate is inherited from base delegate class of .NET class library when it is declared. This can be from either of the two classes from System.Delegate or System.MulticastDelegate.&lt;br /&gt;&lt;br /&gt;If the delegate contains a return type of void, then it is automatically aliased to the type of System.MulticastDelegate. This can support multiple functions with a += operator. If the delegate contains a non-void return type then it is aliased to System.Delegate class and it cannot support multiple methods. &lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;A delegate is a class that encapsulates a method signature. Although it can be used in any context, it often serves as the basis for the event-handling model in C# but can be used in a context removed from event handling (e.g. passing a method to a method through a delegate parameter). &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;em&gt;public delegate int DelegateMethod(int x, int y);&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate. This makes is possible to programmatically change method calls, and also plug new code into existing classes. As long as you know the delegate's signature, you can assign your own-delegated method.&lt;br /&gt;&lt;br /&gt;This ability to refer to a method as a parameter makes delegates ideal for defining callback methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Delegate magic&lt;/strong&gt; &lt;strong&gt;:&lt;/strong&gt; &lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;In class we create its object, which is instance, but in delegate when we create instance that is also referred as delegate (means whatever you do you will get delegate).&lt;br /&gt;&lt;br /&gt;Delegate does not know or care about the class of the object that it references. Any object will do; all that matters is that the method's argument types and return type match the delegate's. This makes delegates perfectly suited for "anonymous" invocation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Benefit of delegates:&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;In simple words delegates are object oriented and type-safe and very secure as they ensure that the signature of the method being called is correct. Delegate helps in code optimization.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Types of delegates:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;1) Singlecast delegates&lt;br /&gt;&lt;br /&gt;2) Multiplecast delegates&lt;br /&gt;&lt;br /&gt;Delegate is a class. Any delegate is inherited from base delegate class of .NET class library when it is declared. This can be from either of the two classes from System.Delegate or System.MulticastDelegate.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Singlecast delegate&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Singlecast delegate point to single method at a time. In this the delegate is assigned to a single method at a time. They are derived from System.Delegate class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Multicast Delegate&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When a delegate is wrapped with more than one method that is known as a multicast delegate.&lt;br /&gt;&lt;br /&gt;In C#, delegates are multicast, which means that they can point to more than one function at a time. They are derived from System.MulticastDelegate class.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;Events in C# .Net:&lt;/em&gt;&lt;/strong&gt; &lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;br /&gt;Delegate usefulness does not just lie in the fact that it can hold the references to functions but in the fact that it can define and use function names at runtime and not at compile time. A large goal of design delegates is their applicability in events model of .Net. Events are the actions of the system on user manipulations (e.g. mouse clicks, key press, timer etc.) or any event triggered by the program . &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;p align="justify"&gt;&lt;span style="font-family:arial;"&gt;Event and delegate are linked together. Event is a reference of delegate i.e. when event will be raised delegate will be called. In C# terms, events are a special form of delegate. Events are nothing but change of state. Events play an important part in GUI programming. Events and delegates work hand-in-hand to provide a program's functionality. A C# event is a class member that is activated whenever the event it was designed for occurs.&lt;br /&gt;&lt;br /&gt;It starts with a class that declares an event. Any class, including the same class that the event is declared in, may register one of its methods for the event. This occurs through a delegate, which specifies the signature of the method that is registered for the event. The event keyword is a delegate modifier. It must always be used in connection with a delegate.&lt;br /&gt;&lt;br /&gt;The delegate may be one of the pre-defined .NET delegates or one you declare yourself. Whichever is appropriate, you assign the delegate to the event, which effectively registers the method that will be called when the event fires. &lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;/span&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;em&gt;obj.MyEvent += new MyDelegate(obj.Display);&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;An event has the value null if it has no registered listeners. Although events are mostly used in Windows controls programming, they can also be implemented in console, web and other applications.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-5820907691173142098?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/5820907691173142098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/delegates-and-events-in-cnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/5820907691173142098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/5820907691173142098'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/delegates-and-events-in-cnet.html' title='Delegates and Events in C#.Net'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-635788729818327167</id><published>2009-06-16T19:33:00.000-07:00</published><updated>2009-06-17T19:00:03.249-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='EJB'/><title type='text'>EJB: Interview Questions</title><content type='html'>&lt;div align="justify"&gt;&lt;strong&gt;1&lt;/strong&gt;.&lt;strong&gt;&lt;span style="font-family:arial;"&gt;Are enterprise beans allowed to use Thread.sleep()?&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;      &lt;span style="font-family:arial;"&gt;Enterprise beans make use of the services provided by the EJB container, such as life-cycle management. To avoid conflicts with these services, enterprise beans are restricted from performing certain operations: Managing or synchronizing threads .&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;2.Is it possible to write two EJB’s that share the same Remote and Home interfaces, and have different bean classes? if so, what are the advantages/disadvantages?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span style="font-family:arial;"&gt; It’s certainly possible. In fact, there’s an example that ships with the Inprise Application Server of an Account interface with separate implementations for CheckingAccount and SavingsAccount, one of which was CMP and one of which was BMP.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family:arial;"&gt;.Is it possible to specify multiple JNDI names when deploying an EJB?&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;       No. To achieve this you have to deploy your EJB multiple times each specifying a different JNDI name.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4.Can an EJB send asynchronous notifications to its clients?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;      Asynchronous notification is a known hole in the first versions of the EJB spec. The recommended solution to this is to use JMS, which is becoming available in J2EE-compliant servers. The other option, of course, is to use client-side threads and polling. This is not an ideal solution, but it’s workable for many scenarios.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5.How can I access EJB from ASP?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;      You can use the Java 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COMBridge 1.0, currently downloadable from Sun.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6.Is there a guarantee of uniqueness for entity beans?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;       There is no such guarantee. The server (or servers) can instantiate as many instances of the same underlying Entity Bean (with the same PK) as it wants. However, each instance is guaranteed to have up-to-date data values, and be transactionally consistent, so uniqueness is not required. This allows the server to scale the system to support multiple threads, multiple concurrent requests, and multiple hosts.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7.How do the six transaction attributes map to isolation levels like “dirty read”? Will an attribute like “Required” lock out other readers until I’m finished updating?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;        The Transaction Attributes in EJB do not map to the Transaction Isolation levels used in JDBC. This is a common misconception. Transaction Attributes specify to the container when a Transaction should be started, suspended(paused) and committed between method invocations on Enterprise JavaBeans. For more details and a summary of Transaction Attributes refer to section 11.6 of the EJB 1.1 specification.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8.Can the primary key in the entity bean be a Java primitive type such as int?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;       The primary key can’t be a primitive type–use the primitive wrapper classes, instead. For example, you can use java.lang.Integer as the primary key class, but not int (it has to be a class, not a primitive)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;9.What’s new in the EJB 2.0 specification?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;         Following are the main features supported in EJB 2.0: Integration of EJB with JMS, Message Driven Beans, Implement additional Business methods in Home interface which are not specific for bean instance, EJB QL.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;10.How many types of protocol implementations does RMI have?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;        RMI has at least three protocol implementations: Java Remote Method Protocol(JRMP), Internet Inter ORB Protocol(IIOP), and Jini Extensible Remote Invocation(JERI). These are alternatives, not part of the same thing, All three are indeed layer 6 protocols for those who are still speaking OSI reference model.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;11.What is the need of Remote and Home interfaces. Why can’t there be one?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;        In a few words, I would say that the main reason is because there is a clear division of roles and responsabilities between the two interfaces. The home interface is your way to communicate with the container, that is who is responsable of creating, locating even removing one or more beans. The remote interface is your link to the bean, that will allow you to remotely access to all its methods and members. As you can see there are two distinct elements (the container and the beans) and you need two different interfaces for accessing to both of them.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;12.What is the difference between Java Beans and EJB?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;        Java Beans are client-side objects and EJBs are server side object, and they have completely different development, lifecycle, purpose.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;13.Does EJB 1.1 support mandate the support for RMI-IIOP ? What is the meaning of “the client API must support the Java RMI-IIOP programming model for portability, but the underlying protocol can be anything” ?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;        EJB1.1 does mandate the support of RMI-IIOP. There are 2 types of implementations that an EJB Server might provide: CORBA-based EJB Servers and Proprietry EJB Servers. Both support the RMI-IIOP API but how that API is implemented is a different story. (NB: By API we mean the interface provided to the client by the stub or proxy). A CORBA-based EJB Server actually implements its EJB Objects as CORBA Objects (it therefore encorporates an ORB and this means that EJB’s can be contacted by CORBA clients (as well as RMI-IIOP clients) A proprietry EJB still implements the RMI-IIOP API (in the client’s stub) but the underlying protocol can be anything. Therefore your EJB’s CANNOT be contacted by CORBA clients. The difference is that in both cases, your clients see the same API (hence, your client portability) BUT how the stubs communicate with the server is different.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;14.What is clustering? What are the different algorithms used for clustering?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;          Clustering is grouping machines together to transparantly provide enterprise services.The client does not now the difference between approaching one server or approaching a cluster of servers.Clusters provide two benefits: scalability and high availability. Further information can be found in the JavaWorld article J2EE Clustering.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;15.What is the advantage of using Entity bean for database operations, over directly using JDBC API to do database operations? When would I use one over the other?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;           Entity Beans actually represents the data in a database. It is not that Entity Beans replaces JDBC API. There are two types of Entity Beans Container Managed and Bean Mananged. In Container Managed Entity Bean – Whenever the instance of the bean is created the container automatically retrieves the data from the DB/Persistance storage and assigns to the object variables in bean for user to manipulate or use them. For this the developer needs to map the fields in the database to the variables in deployment descriptor files (which varies for each vendor). In the Bean Managed Entity Bean – The developer has to specifically make connection, retrive values, assign them to the objects in the ejbLoad() which will be called by the container when it instatiates a bean object. Similarly in the ejbStore() the container saves the object values back the the persistance storage. ejbLoad and ejbStore are callback methods and can be only invoked by the container. Apart from this, when you use Entity beans you dont need to worry about database transaction handling, database connection pooling etc. which are taken care by the ejb container. But in case of JDBC you have to explicitly do the above features. what suresh told is exactly perfect. ofcourse, this comes under the database transations, but i want to add this. the great thing about the entity beans of container managed, whenever the connection is failed during the transaction processing, the database consistancy is mantained automatically. the container writes the data stored at persistant storage of the entity beans to the database again to provide the database consistancy. where as in jdbc api, we, developers has to do manually.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;16.What is the role of serialization in EJB?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;         A big part of EJB is that it is a framework for underlying RMI: remote method invocation. You’re invoking methods remotely from JVM space ‘A’ on objects which are in JVM space ‘B’ — possibly running on another machine on the network. To make this happen, all arguments of each method call must have their current state plucked out of JVM ‘A’ memory, flattened into a byte stream which can be sent over a TCP/IP network connection, and then deserialized for reincarnation on the other end in JVM ‘B’ where the actual method call takes place. If the method has a return value, it is serialized up for streaming back to JVM A. Thus the requirement that all EJB methods arguments and return values must be serializable. The easiest way to do this is to make sure all your classes implement java.io.Serializable.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;17.What is EJB QL?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;           EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. EJB QL is introduced in the EJB 2.0 specification. The EJB QL query language defines finder methods for entity beans with container managed persistenceand is portable across containers and persistence managers. EJB QL is used for queries of two types of finder methods: Finder methods that are defined in the home interface of an entity bean and which return entity objects. Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-635788729818327167?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/635788729818327167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ejb-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/635788729818327167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/635788729818327167'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ejb-interview-questions.html' title='EJB: Interview Questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-8405776366269409614</id><published>2009-06-16T19:23:00.000-07:00</published><updated>2009-06-17T19:08:40.079-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET interview Questions'/><title type='text'>ASP.NET : Interview Questions</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;1.Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.What’s the difference between Response.Write() andResponse.Output.Write()?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Response.Output.Write() allows you to write formatted output.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3.What methods are fired during the page load?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Init() - when the page is instantiated&lt;br /&gt;Load() - when the page is loaded into server memory&lt;br /&gt;PreRender() - the brief moment before the page is displayed to the user as HTML&lt;br /&gt;Unload() - when page finishes loading.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4.When during the page processing cycle is ViewState available?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;After the Init() and before the Page_Load(), or OnLoad() for a control.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5.What namespace does the Web page belong in the .NET Framework class hierarchy?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6.Where do you store the information about the user’s locale?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;System.Web.UI.Page.Culture&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7.What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;CodeBehind is relevant to Visual Studio.NET only.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8.What’s a bubbled event?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;9.Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;10.What data types do the RangeValidator control support?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Integer, String, and Date.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;11.Explain the differences between Server-side and Client-side code?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Server-side code executes on the server. Client-side code executes in the client's browser.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;12.What type of code (server or client) is found in a Code-Behind class?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The answer is server-side code since code-behind is executed on the server. However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;13.Should user input data validation occur server-side or client-side? Why?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;14What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;15.Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Valid answers are:&lt;br /&gt;· A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.&lt;br /&gt;· A DataSet is designed to work without any continuing connection to the original data source.&lt;br /&gt;· Data in a DataSet is bulk-loaded, rather than being loaded on demand.&lt;br /&gt;· There's no concept of cursor types in a DataSet.&lt;br /&gt;· DataSets have no current record pointer You can use For Each loops to move through the data.&lt;br /&gt;· You can store many edits in a DataSet, and write them to the original data source in a single operation.&lt;br /&gt;· Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;16.What is the Global.asax used for?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;17.What are the Application_Start and Session_Start subroutines used for?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;This is where you can set the specific variables for the Application and Session objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;18.Can you explain what inheritance is and an example of when you might use it?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;19.Whats an assembly?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;20.Describe the difference between inline and code behind?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;21.Explain what a diffgram is, and a good use for one?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;22.Whats MSIL, and why should my developers need an appreciation of it if at all?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;23.Which method do you invoke on the DataAdapter control to load your generated dataset with data?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Fill() method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;24.Can you edit data in the Repeater control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;No, it just reads the information from its data source.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;25.Which template must you provide, in order to display data in a Repeater control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;ItemTemplate.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;26.How can you provide an alternating color scheme in a Repeater control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Use the AlternatingItemTemplate.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;27.What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;You must set the DataSource property and call the DataBind method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;28.What base class do all Web Forms inherit from?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Page class.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;29.Name two properties common in every validation control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;ControlToValidate property and Text property.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;30.Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;DataTextField property.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;31.Which control would you use if you needed to make sure the values in two different controls matched?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;CompareValidator control.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;32.How many classes can a single .NET DLL contain?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It can contain many classes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;33.Difference between Application and Session Events&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The ASP.NET page framework provides ways for you to work with events that can be raised when your application starts or stops or when an individual user's session starts or stops:&lt;br /&gt;Application events are raised for all requests to an application. For example, Application_BeginRequest is raised when any Web Forms page or XML Web service in your application is requested. This event allows you to initialize resources that will be used for each request to the application. A corresponding event, Application_EndRequest, provides you with an opportunity to close or otherwise dispose of resources used for the request.&lt;br /&gt;Session events are similar to application events (there is a Session_OnStart and a Session_OnEnd event), but are raised with each unique session within the application. A session begins when a user requests a page for the first time from your application and ends either when your application explicitly closes the session or when the session times out.&lt;br /&gt;You can create handlers for these types of events in the Global.asax file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;34. Difference between ASP Session and ASP.NET Session?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;asp.net session supports cookie less session &amp;amp; it can span across multiple servers.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;35. What is cookie less session? How it works?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;By default, ASP.NET will store the session state in the same process that processes the request, just as ASP does. If cookies are not available, a session can be tracked by adding a session identifier to the URL. This can be enabled by setting the following:&lt;br /&gt;&lt;sessionstate cookieless="true"&gt;&lt;br /&gt;http://samples.gotdotnet.com/quickstart/aspplus/doc/stateoverview.aspx&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;36. How you will handle session when deploying application in more than a server? Describe session handling in a webfarm, how does it work and what are the limits?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;By default, ASP.NET will store the session state in the same process that processes the request, just as ASP does. Additionally, ASP.NET can store session data in an external process, which can even reside on another machine. To enable this feature:&lt;br /&gt;Start the ASP.NET state service, either using the Services snap-in or by executing "net start aspnet_state" on the command line. The state service will by default listen on port 42424. To change the port, modify the registry key for the service: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\Port&lt;br /&gt;Set the mode attribute of the &lt;sessionstate&gt;section to "StateServer".&lt;br /&gt;Configure the stateConnectionString attribute with the values of the machine on which you started aspnet_state.&lt;br /&gt;The following sample assumes that the state service is running on the same machine as the Web server ("localhost") and uses the default port (42424):&lt;br /&gt;&lt;sessionstate mode="StateServer" stateconnectionstring="tcpip=localhost:42424"&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;37. What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Web pages are recreated each time the page is posted to the server. In traditional Web programming, this would ordinarily mean that all information associated with the page and the controls on the page would be lost with each round trip.&lt;br /&gt;To overcome this inherent limitation of traditional Web programming, the ASP.NET page framework includes various options to help you preserve changes — that is, for managing state. The page framework includes a facility called view state that automatically preserves property values of the page and all the controls on it between round trips.&lt;br /&gt;However, you will probably also have application-specific values that you want to preserve. To do so, you can use one of the state management options.&lt;br /&gt;Client-Based State Management Options:&lt;br /&gt;View State&lt;br /&gt;Hidden Form Fields&lt;br /&gt;Cookies&lt;br /&gt;Query Strings&lt;br /&gt;Server-Based State Management Options&lt;br /&gt;Application State&lt;br /&gt;Session State&lt;br /&gt;Database Support&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;38. What are the disadvantages of view state / what are the benefits?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Automatic view-state management is a feature of server controls that enables them to repopulate their property values on a round trip (without you having to write any code). This feature does impact performance, however, since a server control's view state is passed to and from the server in a hidden form field. You should be aware of when view state helps you and when it hinders your page's performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;39. When maintaining session through Sql server, what is the impact of Read and Write operation on Session objects? will performance degrade?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Maintaining state using database technology is a common practice when storing user-specific information where the information store is large. Database storage is particularly useful for maintaining long-term state or state that must be preserved even if the server must be restarted.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;40.What type of code (server or client) is found in a Code-Behind class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;C#&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;41.Should validation (did the user enter a real date) occur server-side or client-side? Why?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Client-side validation because there is no need to request a server side date when you could obtain a date from the client machine.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;42.What are ASP.NET Web Forms? How is this technology different than what is available though ASP?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Web Forms are the heart and soul of ASP.NET. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar drag-and-drop interface used to create your UI for your Web application.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;43.What base class do all Web Forms inherit from?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;44.How do you turn off cookies for one page in your site?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the user’s hard disk when a session ends.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;45.Which two properties are on every validation control?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;ControlToValidate &amp;amp; ErrorMessage properties&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;46.How do you create a permanent cookie?&lt;/strong&gt; &lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Setting the Expires property to MinValue means that the Cookie never expires.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;47.What does WSDL stand for? &lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div align="justify"&gt;&lt;br /&gt;Web Services Description Language&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;48.What tags do you need to add within the asp:datagrid tags to bind columns manually?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;Column tag and an ASP:databound tag.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-8405776366269409614?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/8405776366269409614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/aspnet-interview-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8405776366269409614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8405776366269409614'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/aspnet-interview-questions.html' title='ASP.NET : Interview Questions'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-7659145860650148668</id><published>2009-06-16T03:38:00.000-07:00</published><updated>2009-06-17T19:09:59.081-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='EJB'/><title type='text'>EJB : An Introduction</title><content type='html'>&lt;div align="justify"&gt;One of Java's most important features is platform independence. Since its arrival, Java has been depicted as "write once, run anywhere". But Enterprise JavaBeans (EJBs) go one step further. They are not only platform independent but also implementation independent. That is, EJBs can run in any application server that implements the EJB specifications.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;Enterprise JavaBeans - An Introduction&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;Enterprise JavaBeans (EJB) is a comprehensive technology that provides the infrastructure for building enterprise-level server-side distributed Java components. The EJB technology provides a distributed component architecture that integrates several enterprise-level requirements such as distribution, transactions, security, messaging, persistence, and connectivity to mainframes and Enterprise Resource Planning (ERP) systems. When compared with other distributed component technologies such as Java RMI and CORBA, the EJB architecture hides most the underlying system-level semantics that are typical of distributed component applications, such as instance management, object pooling, multiple threading, and connection pooling. Secondly, unlike other component models, EJB technology provides us with different types of components for business logic, persistence, and enterprise messages.&lt;br /&gt;&lt;br /&gt;Thus, an Enterprise Java Bean is a remote object with semantics specified for creation, invocation and deletion.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size:130%;"&gt;EJB Architecture&lt;/span&gt;&lt;br /&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;Any distributed component technology should have the following requirements:&lt;br /&gt;&lt;br /&gt;1. There should be a mechanism to create the client-side and server-side proxy objects. A client-side proxy represents the server-side object on the client-side. As far as the client is concerned, the client-side proxy is equivalent to the server-side object. On the other hand, the purpose of the server-side proxy is to provide the basic infrastructure to receive client requests and delegate these request to the actual implementation object&lt;br /&gt;&lt;br /&gt;2. We need to obtain a reference to client-side proxy object. In order to communicate with the server-side object, the client needs to obtain a reference to the proxy.&lt;br /&gt;&lt;br /&gt;3. There should be a way to inform the distributed component system that a specific component is no longer in use by the client.&lt;br /&gt;&lt;br /&gt;In order to meet these requirements, the EJB architecture specifies two kinds of interfaces for each bean. They are home interface and remote interface. These interfaces specify the bean contract to the clients. However, a bean developer need not provide implementation for these interfaces. The home interface will contain methods to be used for creating remote objects. The remote interface should include business methods that a bean is able to serve to clients. One can consider using the home interface to specify a remote object capable of creating objects conforming to the remote interface. That is, a home interface is analogous to a factory of remote objects. These are regular Java interfaces extending the javax.ejb.EJBHome and javax.ejb.EJBObject interfaces respectively.&lt;br /&gt;&lt;br /&gt;The EJB architecture specifies three types of beans - session beans, entity beans, and message-driven beans. A bean developer has to specify the home and remote interfaces and also he has to implement one of these bean interfaces depending upon the type of the bean. For instance, for session beans, he has to implement the javax.ejb.SessionBean interface. The EJB architecture expects him to implement the methods specified in the bean interface and the methods specified in the home and remote interfaces. During the deployment time, he should specify the home and remote interfaces and bean implementation class to define a bean. The EJB container relies on specific method names and uses delegation for invoking methods on bean instances.&lt;br /&gt;&lt;br /&gt;Thus regarding the first requirement, the EJB container generates the proxy objects for all beans. For the second one, the EJB container for each bean implement a proxy object to the home interface and publishes in the JNDI implementation of the J2EE platform. One can use JNDI to look for this and obtain a reference. As this object implements the home interface only, he can use one of the creation methods of the home object to get a proxy to the remote interface of the bean. When one invokes a creation method on the home proxy object, the container makes sure that a bean instance is created on the EJB container runtime and its proxy is returned to the client. Once the client gets hold of the proxy for the remote interface, it can directly access the services of the bean.&lt;br /&gt;&lt;br /&gt;Finally, once the client decides to stop accessing the services of the bean, it can inform the EJB container by calling a remote method on the bean. This signals the EJB container to disassociate the bean instance from the proxy and that bean instance is ready to service any other clients.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-7659145860650148668?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/7659145860650148668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ejb-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7659145860650148668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7659145860650148668'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/ejb-introduction.html' title='EJB : An Introduction'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-703685475266274854</id><published>2009-06-14T23:04:00.000-07:00</published><updated>2009-06-17T20:26:53.703-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Questions'/><title type='text'>Interview Questions:JAVA</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;1. What are order of precedence and associativity, and how are they used?&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;2. What is a transient variable?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A transient variable is a variable that may not be serialized.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Which containers use a border Layout as their default layout?&lt;/strong&gt;&lt;br /&gt;The window, Frame and Dialog classes use a border layout as their default layout.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Why do threads block on I/O?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. How are Observer and Observable used?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. What is synchronization and why is it important?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. Can a lock be acquired on a class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8. What's new with the stop(), suspend() and resume() methods in JDK 1.2?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;9. Is null a keyword?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The null value is not a keyword.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;10. What is the preferred size of a component?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The preferred size of a component is the minimum component size that will allow the component to display normally.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;11. What method is used to specify a container's layout&lt;/strong&gt;?&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The setLayout() method is used to specify a container's layout.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;12. Which containers use a FlowLayout as their default layout?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Panel and Applet classes use the FlowLayout as their default layout.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;13. What state does a thread enter when it terminates its processing?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When a thread terminates its processing, it enters the dead state.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;14. What is the Collections API?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Collections API is a set of classes and interfaces that support operations on collections of objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;15. which characters may be used as the second character of an identifier, but not as the first character of an identifier?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;16. What is the List interface?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The List interface provides support for ordered collections of objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;17. How does Java handle integer overflows and underflows?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;18. What is the Vector class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Vector class provides the capability to implement a growable array of objects&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;19. What modifiers may be used with an inner class that is a member of an outer class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;20. What is an Iterator interface?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Iterator interface is used to step through the elements of a Collection.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;21. What is the difference between the &gt;&gt; and &gt;&gt;&gt; operators?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The &gt;&gt; operator carries the sign bit when shifting right. The &gt;&gt;&gt; zero-fills bits that have been shifted out.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;22. Which method of the Component class is used to set the position and size of a component?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;setBounds()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;23. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;24. What is the difference between yielding and sleeping?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;25. Which java.util classes and interfaces support event handling?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The EventObject class and the EventListener interface support event processing.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;26. Is sizeof a keyword?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The sizeof operator is not a keyword.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;27. What are wrapper classes?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Wrapper classes are classes that allow primitive types to be accessed as objects.&lt;br /&gt;&lt;/div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;28. Does garbage collection guarantee that a program will not run out of memory?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;29. What restrictions are placed on the location of a package statement within a source code file?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A package statement must appear as the first line in a source code file (excluding blank lines and comments).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;30. Can an object's finalize() method be invoked while it is reachable?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize() method may be invoked by other objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;31. What is the immediate superclass of the Applet class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Panel&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;32. What is the difference between preemptive scheduling and time slicing?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;33. Name three Component subclasses that support painting.&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Canvas, Frame, Panel, and Applet classes support painting.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;34. What value does readLine() return when it has reached the end of a file?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The readLine() method returns null when it has reached the end of a file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;35. What is the immediate superclass of the Dialog class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Window.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;36. What is clipping?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Clipping is the process of confining paint operations to a limited area or shape.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;37. What is a native method?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A native method is a method that is implemented in a language other than Java.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;38. Can a for statement loop indefinitely?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Yes, a for statement can loop indefinitely. For example, consider the following:&lt;br /&gt;for(;;) ;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;strong&gt;39. When a thread blocks on I/O, what state does it enter?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A thread enters the waiting state when it blocks on I/O.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;40. To what value is a variable of the String type automatically initialized?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The default value of a String type is null.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;41. What is the catch or declare rule for method declarations?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;42. What is the difference between a MenuItem and a CheckboxMenuItem?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;43. What is a task's priority and how is it used in scheduling?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;44. What class is the top of the AWT event hierarchy?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;45. When a thread is created and started, what is its initial state?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A thread is in the ready state after it has been created and started.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;46. Can an anonymous class be declared as implementing an interface and extending a class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;47. What is the range of the short type?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The range of the short type is -(2^15) to 2^15 - 1.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;48. What is the range of the char type?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The range of the char type is 0 to 2^16 - 1.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;49. In which package are most of the AWT events that support the event-delegation model defined?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;50. What is the immediate superclass of Menu?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;MenuItem&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;51. What is the purpose of finalization?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;52. Which class is the immediate superclass of the MenuComponent class.&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Object&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;53. What invokes a thread's run() method?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;54. What is the difference between the Boolean &amp;amp; operator and the &amp;amp;&amp;amp; operator?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;If an expression involving the Boolean &amp;amp; operator is evaluated, both operands are evaluated. Then the &amp;amp; operator is applied to the operand. When an expression involving the &amp;amp;&amp;amp; operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The &amp;amp;&amp;amp; operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;55. Name three subclasses of the Component class.&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;56. What is the GregorianCalendar class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The GregorianCalendar provides support for traditional Western calendars.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;57. Which Container method is used to cause a container to be laid out and redisplayed?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;validate()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;58. What is the purpose of the Runtime class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The purpose of the Runtime class is to provide access to the Java runtime system.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;59. How many times may an object's finalize() method be invoked by the&lt;br /&gt;garbage collector?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object's finalize() method may only be invoked once by the garbage collector.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;60. What is the purpose of the finally clause of a try-catch-finally statement?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;61. What is the argument type of a program's main() method?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A program's main() method takes an argument of the String[] type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;62. Which Java operator is right associative?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The = operator is right associative.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;63. What is the Locale class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.64. Can a double value be cast to a byte?&lt;br /&gt;Yes, a double value can be cast to a byte.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;65. What is the difference between a break statement and a continue statement?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;66. What must a class do to implement an interface?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It must provide all of the methods in the interface and identify the interface in its implements clause.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;67. What method is invoked to cause an object to begin executing as a separate thread?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;68. Name two subclasses of the TextComponent class.&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;TextField and TextArea&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;69. What is the advantage of the event-delegation model over the earlier event-inheritance model?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component's design and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance&lt;br /&gt;model.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;70. Which containers may have a MenuBar?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Frame&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;71. How are commas used in the initialization and iteration parts of a for statement?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;72. What is the purpose of the wait(), notify(), and notifyAll() methods?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;73. What is an abstract method?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An abstract method is a method whose implementation is deferred to a subclass.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;74. How are Java source code files named?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;75. What is the relationship between the Canvas class and the Graphics class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A Canvas object provides access to a Graphics object via its paint() method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;76. What are the high-level thread states?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The high-level thread states are ready, running, waiting, and dead.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;77. What value does read() return when it has reached the end of a file?&lt;/strong&gt;&lt;br /&gt;The read() method returns -1 when it has reached the end of a file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;78. Can a Byte object be cast to a double value? &lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;No, an object cannot be cast to a primitive value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;79. What is the difference between a static and a non-static inner class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;80. What is the difference between the String and StringBuffer classes?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;String objects are constants. StringBuffer objects are not.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;81. If a variable is declared as private, where may the variable be accessed?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A private variable may only be accessed within the class in which it is declared.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;82. What is an object's lock and which objects have locks?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;83. What is the Dictionary class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Dictionary class provides the capability to store key-value pairs.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;84. How are the elements of a BorderLayout organized?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;85. What is the % operator?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;86. When can an object reference be cast to an interface reference?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object reference be cast to an interface reference when the object implements the referenced interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;87. What is the difference between a Window and a Frame?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Frame class extends Window to define a main application window that can have a menu bar.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;88. Which class is extended by all other classes?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Object class is extended by all other classes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;89. Can an object be garbage collected while it is still reachable?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;90. Is the ternary operator written x : y ? z or x ? y : z ?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It is written x ? y : z.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;91. What is the difference between the Font and FontMetrics classes?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;92. How is rounding performed under integer division?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The fractional part of the result is truncated. This is known as rounding toward zero.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;93. What happens when a thread cannot acquire a lock on an object?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;94. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;95. What classes of exceptions may be caught by a catch clause?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;96. If a class is declared without any access modifiers, where may the class be accessed?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;97. What is the SimpleTimeZone class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The SimpleTimeZone class provides support for a Gregorian calendar.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;98. What is the Map interface?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;99. Does a class inherit the constructors of its superclass?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A class does not inherit constructors from any of its super classes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;100. For which statements does it make sense to use a label?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;101. What is the purpose of the System class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The purpose of the System class is to provide access to system resources.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;102. Which TextComponent method is used to set a TextComponent to the read-only state?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;setEditable()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;103. How are the elements of a CardLayout organized?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;104. Is &amp;amp;&amp;amp;= a valid Java operator?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;No, it is not.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;105. Name the eight primitive Java types.&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The eight primitive types are byte, char, short, int, long, float, double, and boolean.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;106. Which class should you use to obtain design information about an object?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;T&lt;/span&gt;&lt;span style="font-family:arial;"&gt;he Class class is used to obtain information about an object's design.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;107. What is the relationship between clipping and repainting?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;108. Is "abc" a primitive value?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The String literal "abc" is not a primitive value. It is a String object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;109. What is the relationship between an event-listener interface and an event-adapter class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;110. What restrictions are placed on the values of each case of a switch statement?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;111. What modifiers may be used with an interface declaration?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An interface may be declared as public or abstract.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;112. Is a class a subclass of itself?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A class is a subclass of itself.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;113. What is the highest-level event class of the event-delegation model?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;114. What event results from the clicking of a button?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The ActionEvent event is generated as the result of the clicking of a button.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;115. How can a GUI component handle its own events?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;116. What is the difference between a while statement and a do statement?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;117. How are the elements of a GridBagLayout organized?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;118. What advantage do Java's layout managers provide over traditional windowing systems?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;119. What is the Collection interface?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;120. What modifiers can be used with a local inner class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A local inner class may be final or abstract.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;121. What is the difference between static and non-static variables?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;122. What is the difference between the paint() and repaint() methods?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;123. What is the purpose of the File class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The File class is used to create objects that provide access to the files and directories of a local file system.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;124. Can an exception be rethrown?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Yes, an exception can be rethrown.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;125. Which Math method is used to calculate the absolute value of a number?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The abs() method is used to calculate absolute values.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;126. How does multithreading take place on a computer with a single CPU?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;127. When does the compiler supply a default constructor for a class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The compiler supplies a default constructor for a class if no other constructors are provided.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;128. When is the finally clause of a try-catch-finally statement executed?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;129. Which class is the immediate superclass of the Container class?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Component&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;130. If a method is declared as protected, where may the method be accessed?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;131. How can the Checkbox class be used to create a radio button?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;By associating Checkbox objects with a CheckboxGroup.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;132. Which non-Unicode letter characters may be used as the first character of an identifier?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The non-Unicode letter characters $ and _ may appear as the first character of an identifier&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;133. What restrictions are placed on method overloading?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Two methods may not have the same name and argument list but different return types.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;134. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;135. What is casting?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;136. What is the return type of a program's main() method?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A program's main() method has a void return type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;137. Name four Container classes.&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;138. What is the difference between a Choice and a List?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;139. What class of exceptions are generated by the Java run-time system?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Java runtime system generates RuntimeException and Error exceptions.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;140. What class allows you to read objects directly from a stream?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The ObjectInputStream class supports the reading of objects from input streams.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;141. What is the difference between a field variable and a local variable?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;142. Under what conditions is an object's finalize() method invoked by the garbage collector?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;143. How are this () and super () used with constructors?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;144. What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A method's throws clause must declare any checked exceptions that are not caught within the body of the method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;145. What is the difference between the JDK 1.02 event model and the event-delegation model introduced with JDK 1.1?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.&lt;br /&gt;In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing required to support the bubbling of unhandled events.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;146. How is it possible for two String objects with identical values not to be equal under the == operator?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;147. Why are the methods of the Math class static?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;So they can be invoked as if they are a mathematical code library.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;148. What Checkbox method allows you to tell if a Checkbox is checked?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;getState()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;149. What state is a thread in when it is executing?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An executing thread is in the running state.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;150. What are the legal operands of the instanceof operator?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The left operand is an object reference or null value and the right operand is a class, interface, or array type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;151. How are the elements of a GridLayout organized?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The elements of a GridBad layout are of equal size and are laid out using the squares of a grid.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;152. What an I/O filter?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;153. If an object is garbage collected, can it become reachable again?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;154. What is the Set interface?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;155. What classes of exceptions may be thrown by a throw statement?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A throw statement may throw any expression that may be assigned to the Throwable type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;156. What are E and PI?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;E is the base of the natural logarithm and PI is mathematical value pi.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;157. Are true and false keywords?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The values true and false are not keywords.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;158. What is a void return type?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A void return type indicates that a method does not return a value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;159. What is the purpose of the enableEvents() method?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;160. What is the difference between the File and RandomAccessFile classes?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;161. What happens when you add a double value to a String?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The result is a String object.162. What is your platform's default character encoding?&lt;br /&gt;If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1..&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;163. Which package is always imported by default?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The java.lang package is always imported by default.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;164. What interface must an object implement before it can be written to a stream as an object?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;165. How are this and super used?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;This is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current object instance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;166. What is the purpose of garbage collection?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed and&lt;br /&gt;reused.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;167. What is a compilation unit?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A compilation unit is a Java source code file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;168. What interface is extended by AWT event listeners?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;All AWT event listeners extend the java.util.EventListener interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;169. What restrictions are placed on method overriding?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Overridden methods must have the same name, argument list, and return type.&lt;br /&gt;The overriding method may not limit the access of the method it overrides.&lt;br /&gt;The overriding method may not throw any exceptions that may not be thrown&lt;br /&gt;by the overridden method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;170. How can a dead thread be restarted?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A dead thread cannot be restarted.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;171. What happens if an exception is not caught?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An uncaught exception results in the uncaughtException() method of the thread's ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;172. What is a layout manager?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A layout manager is an object that is used to organize components in a container.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;173. Which arithmetic operations can result in the throwing of an ArithmeticException?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Integer / and % can result in the throwing of an ArithmeticException.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;174. What are three ways in which a thread can enter the waiting state?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its&lt;br /&gt;(deprecated) suspend() method.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;175. Can an abstract class be final?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An abstract class may not be declared as final.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;176. What is the ResourceBundle class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;177. What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The exception propagates up to the next higher level try-catch statement (if any) or results in the program's termination.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;178. What is numeric promotion?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int&lt;br /&gt;values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;179. What is the difference between a Scrollbar and a ScrollPane?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;180. What is the difference between a public and a non-public class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;181. To what value is a variable of the boolean type automatically initialized?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The default value of the boolean type is false.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;182. Can try statements be nested?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Try statements may be tested.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;183. What is the difference between the prefix and postfix forms of the ++ operator?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;184. What is the purpose of a statement block?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A statement block is used to organize a sequence of statements as a single statement group.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;185. What is a Java package and how is it used?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;186. What modifiers may be used with a top-level class?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A top-level class may be public, abstract, or final.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;187. What are the Object and Class classes used for?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are loaded by a Java program.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;188. How does a try statement determine which catch clause should be used to handle an exception?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed.&lt;br /&gt;The remaining catch clauses are ignored.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;189. Can an unreachable object become reachable again?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;190. When is an object subject to garbage collection?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;An object is subject to garbage collection when it becomes unreachable to the program in which it is used.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;191. What method must be implemented by all threads?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;192. What methods are used to get and set the text label displayed by a Button object?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;getLabel() and setLabel()&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;193. Which Component subclass is used for drawing and painting?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Canvas&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;194. What are synchronized methods and synchronized statements?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;195. What are the two basic ways in which classes that can be run as threads may be defined?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;196. What are the problems faced by Java programmers who don't use layout managers?&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;197. What is the difference between an if statement and a switch statement?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed&lt;/span&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-703685475266274854?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/703685475266274854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/interview-questionsjava.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/703685475266274854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/703685475266274854'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/interview-questionsjava.html' title='Interview Questions:JAVA'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-8852491958405081250</id><published>2009-06-14T18:36:00.000-07:00</published><updated>2009-06-17T20:31:57.926-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Technical Questions'/><title type='text'>Technical Aptitude questions on SQL</title><content type='html'>&lt;div align="justify"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6x7f4IRM3KI/SjWocW_dhoI/AAAAAAAAAAs/JA61B1tNZpM/s1600-h/question%2520mark.jpg"&gt;&lt;img style="MARGIN: 0pt 10px 10px 0pt; WIDTH: 320px; FLOAT: left; HEIGHT: 228px; CURSOR: pointer" id="BLOGGER_PHOTO_ID_5347365337733891714" border="0" alt="" src="http://2.bp.blogspot.com/_6x7f4IRM3KI/SjWocW_dhoI/AAAAAAAAAAs/JA61B1tNZpM/s320/question%2520mark.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;1. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Data Definition Language (DDL)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. What operator performs pattern matching?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;LIKE operator&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. What operator tests column for the absence of data?&lt;br /&gt;&lt;/strong&gt;IS NULL operator&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;4. Which command executes the contents of a specified file?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;START &lt;filename&gt;or @&lt;filename&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. What is the parameter substitution symbol used with INSERT INTO command?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&amp;amp;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Which command displays the SQL command in the SQL buffer, and then executes it?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;RUN&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. What are the wildcards used for pattern matching?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;_ for single character substitution and % for multi-character substitution&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8. State true or false. EXISTS, SOME, ANY are operators in SQL.&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;True&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;9. State true or false. !=, &lt;&gt;, ^= all denote the same operation.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;True&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;10. What are the privileges that can be granted on a table by a user to others?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Insert, update, delete, select, references, index, execute, alter, all&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;11. What command is used to get back the privileges offered by the GRANT command?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;REVOKE&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;12. Which system tables contain information on privileges granted and privileges&lt;br /&gt;obtained?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;13. Which system table contains information on constraints on all the tables created?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;USER_CONSTRAINTS&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;14. TRUNCATE TABLE EMP;&lt;br /&gt;DELETE FROM EMP;&lt;br /&gt;Will the outputs of the above two commands differ?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;Both will result in deleting all the rows in the table EMP.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;15. What is the difference between TRUNCATE and DELETE commands?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;16. What command is used to create a table by copying the structure of another table?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;CREATE TABLE .. AS SELECT command&lt;br /&gt;Explanation :&lt;br /&gt;To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.&lt;br /&gt;CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;&lt;br /&gt;If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;17. What will be the output of the following query?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM DUAL;&lt;br /&gt;TROUBLETHETROUBLE&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;18. What will be the output of the following query?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );&lt;br /&gt;Answer :&lt;br /&gt;NO&lt;br /&gt;Explanation :&lt;br /&gt;The query checks whether a given string is a numerical digit.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;19. What does the following query do?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;SELECT SAL + NVL(COMM,0) FROM EMP;&lt;br /&gt;This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;&lt;strong&gt;20. Which date function is used to find the difference between two dates?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;MONTHS_BETWEEN&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;21. Why does the following command give a compilation error?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;DROP TABLE &amp;amp;TABLE_NAME;&lt;br /&gt;Variable names should start with an alphabet. Here the table name starts with an '&amp;amp;' symbol.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;22. What is the advantage of specifying WITH GRANT OPTION in the GRANT command?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;23. What is the use of the DROP option in the ALTER TABLE command?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;It is used to drop constraints specified on the table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;24. What is the value of ‘comm’ and ‘sal’ after executing the following query if the initial value of ‘sal’ is 10000?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;&lt;br /&gt;sal = 11000, comm = 1000&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;25. What is the use of DESC in SQL?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.&lt;br /&gt;Explanation :&lt;br /&gt;The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;26. What is the use of CASCADE CONSTRAINTS?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;27. Which function is used to find the largest integer less than or equal to a specific value? &lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;FLOOR&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;28. What is the output of the following query?&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:arial;"&gt;SELECT TRUNC(1234.5678,-2) FROM DUAL;&lt;br /&gt;1200&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/filename&gt;&lt;/filename&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-8852491958405081250?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/8852491958405081250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/technical-aptitude-questions-on-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8852491958405081250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/8852491958405081250'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/technical-aptitude-questions-on-sql.html' title='Technical Aptitude questions on SQL'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6x7f4IRM3KI/SjWocW_dhoI/AAAAAAAAAAs/JA61B1tNZpM/s72-c/question%2520mark.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-6685880636195482446</id><published>2009-06-14T05:22:00.000-07:00</published><updated>2009-06-14T05:27:24.686-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Applications'/><title type='text'>Creating Web Applications A Small Overview</title><content type='html'>&lt;span style="font-weight: bold;"&gt;System Input and Output&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since the user interface function takes place through a Web browser running on the PC client, you can use development tools that program the browser to perform output formatting, data entry, and data validation tasks, among others. For these purposes you need knowledge of markup languages such as XHTML and CSS (Cascading Style Sheets) to structure and present system input and output. Of increasing importance are markup language extensions such as DHTML (Dynamic HTML) for user interactions with the Web page and XML (eXtensible Markup Language) for representing data structures that are delivered by the server for processing on the browser. Also, the primary programming language for the browser is JavaScript, which is used to manipulate markup languages and data structures to perform browser processing tasks.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;System Processing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the Web server side you need to be able to write applications to perform the main processing activities of the system. Server languages such as Visual Basic and C# (C sharp) are used to code these routines. One the one hand, these languages function as full-features programming languages to code the arithmetic and logical details of processing; on the other hand, they call upon built-in server processing components to perform the main or ancillary work of the system. The Microsoft .NET technologies, implemented as ASP (Active Server Pages).NET, is one such collection of processing components. Through this set of software objects the Web programmer can perform virtually any processing task without having to code elaborate sets of detailed instructions. Of course, the energetic programmer can code Web applications in conventional languages such as C++, Java, and the like, or can code specialized software components callable through Visual Basic or C# for application of their processing functions to the task at hand.&lt;br /&gt;&lt;br /&gt;It is more accurate to think of server languages such as Visual Basic and C# as scripting languages rather than programming languages. Their use is in tying together prebuilt components from, say, the .NET framework, moreso than in writing intricate processing details. This is becoming the nature of Web applications development, producing a logical roadmap of processing tasks which are implemented as preprogrammed, black-box components adaptable to specific processing needs. A Web script, rather than being a computer program, is a processing control structures to call upon available software components to perform the work of the system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Database Management&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On the database server side, languages such as SQL (Structured Query Language) perform the data storage, maintenance, and access functions to keep information up to date and accurate for Web presentation. In addition, database programming languages are used to code command procedures, processing functions stored within databases to extract from, update, and report on their contents. Server languages call upon these SQL commands and stored procedures to perform their associated processing, saving the developer from having to code the low-level access details directly. ADO (Active-X Data Objects).NET components provide the interface between scripting languages and these data access routines in order hide the complexity of data access. Of increasing importance in data storage and electronic data interchange are XML data structures. Being able to convert between standard file and database formats to XML formats is becoming a crucial Web development skill.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6x7f4IRM3KI/SjTsI9n1LFI/AAAAAAAAAAg/GHoggTnlnh0/s1600-h/III+Tier3.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 253px; height: 408px;" src="http://3.bp.blogspot.com/_6x7f4IRM3KI/SjTsI9n1LFI/AAAAAAAAAAg/GHoggTnlnh0/s320/III+Tier3.gif" alt="" id="BLOGGER_PHOTO_ID_5347158296320355410" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-6685880636195482446?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/6685880636195482446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/creating-web-applications-small.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/6685880636195482446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/6685880636195482446'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2009/06/creating-web-applications-small.html' title='Creating Web Applications A Small Overview'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_6x7f4IRM3KI/SjTsI9n1LFI/AAAAAAAAAAg/GHoggTnlnh0/s72-c/III+Tier3.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-3272722137690910143</id><published>2008-08-26T05:15:00.000-07:00</published><updated>2009-06-14T04:55:01.862-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL INDEXING'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL Server INDEXING Tutorial</title><content type='html'>Relational databases like SQL Server use indexes to find data quickly when a query is processed. Creating and removing indexes from a database schema will rarely result in changes to an application's code; indexes operate 'behind the scenes' in support of the database engine. However, creating the proper index can drastically increase the performance of an application. &lt;br /&gt;&lt;br /&gt;The SQL Server engine uses an index in much the same way a reader uses a book index. For example, one way to find all references to INSERT statements in a SQL book would be to begin on page one and scan each page of the book. We could mark each time we find the word INSERT until we reach the end of the book. This approach is pretty time consuming and laborious. Alternately, we can also use the index in the back of the book to find a page number for each occurrence of the INSERT statements. This approach produces the same results as above, but with tremendous savings in time. &lt;br /&gt;&lt;br /&gt;When a SQL Server has no index to use for searching, the result is similar to the reader who looks at every page in a book to find a word: the SQL engine needs to visit every row in a table. In database terminology we call this behavior a table scan, or just scan. &lt;br /&gt;&lt;br /&gt;A table scan is not always a problem, and is sometimes unavoidable. However, as a table grows to thousands of rows and then millions of rows and beyond, scans become correspondingly slower and more expensive.&lt;br /&gt;&lt;br /&gt;Consider the following query on the Products table of the Northwind database. This query retrieves products in a specific price range.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;SELECT ProductID, ProductName, UnitPrice&lt;/i&gt;&lt;br /&gt;&lt;i&gt;FROM Products WHERE (UnitPrice &amp;gt; 12.5) AND (UnitPrice &amp;lt; 14)&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;There is currently no index on the Product table to help this query, so the database engine performs a scan and examines each record to see if UnitPrice falls between 12.5 and 14. In the diagram below, the database search touches a total of 77 records to find just three matches.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP3Htjm_dI/AAAAAAAACW0/9-oM48pcZf8/s1600-h/INDEX12.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP3Htjm_dI/AAAAAAAACW0/KqIERlIQn1E/s400-R/INDEX12.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;Now imagine if we created an index, just like a book index, on the data in the UnitPrice column. Each index entry would contain a copy of the UnitPrice value for a row, and a reference (just like a page number) to the row where the value originated. SQL will sort these index entries into ascending order. The index will allow the database to quickly narrow in on the three rows to satisfy the query, and avoid scanning every row in the table. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Create An Index&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Having a data connection in the Server Explorer view of Visual Studio.NET allows us to easily create new indexes:&lt;br /&gt;• Navigate to the Products table of the Northwind database. &lt;br /&gt;• Right click the table and select Design Table from the context menu. &lt;br /&gt;• With the design screen in focus, click the Indexes/Keys item on the View menu of the IDE. &lt;br /&gt;&lt;br /&gt;This should bring you to the following tabbed dialog box. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP3InaK6kI/AAAAAAAACW8/3TKm72iGSZ8/s1600-h/INDEX1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP3InaK6kI/AAAAAAAACW8/GJONP-EzY2c/s400-R/INDEX1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The dialog is currently displaying an existing index on the Products table: the PK_Products index. We will see later in this chapter how primary key fields are automatically indexed to enforce uniqueness in the key values.&lt;br /&gt;&lt;br /&gt;• In the above dialog click on the New button, and in the Index name text box, replace the existing entry with IDX_UnitPrice. &lt;br /&gt;• Beneath the text box is a control where we set the columns to index. Pull down the entry with ProductID and select the UnitPrice column instead.&lt;br /&gt;• Leave all of the other options with default settings.&lt;br /&gt;• Close the dialog and the table design view, making sure to save all of the changes when prompted to do so. The IDE will then issue the commands to create the new index.&lt;br /&gt;&lt;br /&gt;We can create the same index using the following SQL. The command specifies the name of the index (IDX_UnitPrice), the table name (Products), and the column to index (UnitPrice).&lt;br /&gt;&lt;i&gt;CREATE INDEX [IDX_UnitPrice] ON Products (UnitPrice)&lt;/i&gt;&lt;br /&gt;To verify that the index is created, use the following stored procedure to see a list of all indexes on the Products table:&lt;br /&gt;&lt;i&gt;EXEC sp_helpindex Customers &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How It Works&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The database takes the columns specified in a CREATE INDEX command and sorts the values into a special data structure known as a B-tree. A B-tree structure supports fast searches with a minimum amount of disk reads, allowing the database engine to quickly find the starting and stopping points for the query we are using.&lt;br /&gt;&lt;br /&gt;Conceptually, we may think of an index as shown in the diagram below. On the left, each index entry contains the index key (UnitPrice). Each entry also includes a reference (which points) to the table rows which share that particular value and from which we can retrieve the required information. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP5XCRYWSI/AAAAAAAACXE/i3LSGujaOiI/s1600-h/INDEX2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP5XCRYWSI/AAAAAAAACXE/tvgd_83ZWNU/s400-R/INDEX2.jpg" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;br /&gt;Much like the index in the back of a book helps us to find keywords quickly, so the database is able to quickly narrow the number of records it must examine to a minimum by using the sorted list of UnitPrice values stored in the index. We have avoided a table scan to fetch the query results. Given this sketch of how indexes work, lets examine some of the scenarios where indexes offer a benefit&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Taking Advantage of Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The database engine can use indexes to boost performance in a number of different queries. Sometimes these performance improvements are dramatic. An important feature of SQL Server 2000 is a component known as the query optimizer. The query optimizer's job is to find the fastest and least resource intensive means of executing incoming queries. An important part of this job is selecting the best index or indexes to perform the task. In the following sections we will examine the types of queries with the best chance of benefiting from an index.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Searching For Records&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The most obvious use for an index is in finding a record or set of records matching a WHERE clause. Indexes can aid queries looking for values inside of a range (as we demonstrated earlier), as well as queries looking for a specific value. By way of example, the following queries can all benefit from an index on UnitPrice:&lt;br /&gt;&lt;br /&gt;DELETE FROM Products WHERE UnitPrice = 1 &lt;br /&gt;&lt;br /&gt;UPDATE Products SET Discontinued = 1 WHERE UnitPrice &amp;gt; 15 &lt;br /&gt;&lt;br /&gt;SELECT * FROM PRODUCTS WHERE UnitPrice BETWEEN 14 AND 16 &lt;br /&gt;&lt;br /&gt;Indexes work just as well when searching for a record in DELETE and UPDATE commands as they do for SELECT statements. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Sorting Records&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When we ask for a sorted dataset, the database will try to find an index and avoid sorting the results during execution of the query. We control sorting of a dataset by specifying a field, or fields, in an ORDER BY clause, with the sort order as ASC (ascending) or DESC (descending). For example, the following query returns all products sorted by price:&lt;br /&gt;&lt;br /&gt;SELECT * FROM Products ORDER BY UnitPrice ASC &lt;br /&gt;&lt;br /&gt;With no index, the database will scan the Products table and sort the rows to process the query. However, the index we created on UnitPrice (IDX_UnitPrice) earlier provides the database with a presorted list of prices. The database can simply scan the index from the first entry to the last entry and retrieve the rows in sorted order. &lt;br /&gt;The same index works equally well with the following query, simply by scanning the index in reverse.&lt;br /&gt;&lt;br /&gt;SELECT * FROM Products ORDER BY UnitPrice DESC &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Grouping Records&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We can use a GROUP BY clause to group records and aggregate values, for example, counting the number of orders placed by a customer. To process a query with a GROUP BY clause, the database will often sort the results on the columns included in the GROUP BY. The following query counts the number of products at each price by grouping together records with the same UnitPrice value.&lt;br /&gt;SELECT Count(*), UnitPrice FROM Products GROUP BY UnitPrice &lt;br /&gt;The database can use the IDX_UnitPrice index to retrieve the prices in order. Since matching prices appear in consecutive index entries, the database is able count the number of products at each price quickly. Indexing a field used in a GROUP BY clause can often speed up a query. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Maintaining a Unique Column&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Columns requiring unique values (such as primary key columns) must have a unique index applied. There are several methods available to create a unique index. Marking a column as a primary key will automatically create a unique index on the column. We can also create a unique index by checking the Create UNIQUE checkbox in the dialog shown earlier. The screen shot of the dialog displayed the index used to enforce the primary key of the Products table. In this case, the Create UNIQUE checkbox is disabled, since an index to enforce a primary key must be a unique index. However, creating new indexes not used to enforce primary keys will allow us to select the Create UNIQUE checkbox. We can also create a unique index using SQL with the following command: &lt;br /&gt;&lt;br /&gt;CREATE UNIQUE INDEX IDX_ProductName On Products (ProductName)&lt;br /&gt;&lt;br /&gt;The above SQL command will not allow any duplicate values in the ProductName column, and an index is the best tool for the database to use to enforce this rule. Each time an application adds or modifies a row in the table, the database needs to search all existing records to ensure none of values in the new data duplicate existing values. Indexes, as we should know by now, will improve this search time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Index Drawbacks&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;There are tradeoffs to almost any feature in computer programming, and indexes are no exception. While indexes provide a substantial performance benefit to searches, there is also a downside to indexing. Let's talk about some of those drawbacks now. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Indexes and Disk Space&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Indexes are stored on the disk, and the amount of space required will depend on the size of the table, and the number and types of columns used in the index. Disk space is generally cheap enough to trade for application performance, particularly when a database serves a large number of users. To see the space required for a table, use the sp_spaceused system stored procedure in a query window.&lt;br /&gt;&lt;br /&gt;EXEC sp_spaceused Orders &lt;br /&gt;&lt;br /&gt;&lt;style&gt;&lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;}.MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;}.MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt;  &lt;br /&gt;&lt;div class="MsoNormal" style="line-height: normal;"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;Given a table name (Orders), the procedure will return the amount of space used by the data and all indexes associated with the table, like so: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; rows&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reserved&amp;nbsp;&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp;&amp;nbsp; index_size&amp;nbsp; unused&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;------- -------- ----------- ------&amp;nbsp; ----------&amp;nbsp; -------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;Orders&amp;nbsp; 830&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 504 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 160 KB&amp;nbsp; 320 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24 KB&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal;"&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal;"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;According to the output above, the table data uses 160 kilobytes, while the table indexes use twice as much, or 320 kilobytes. The ratio of index size to table size can vary greatly, depending on the columns, data types, and number of indexes on a table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal;"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal;"&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Indexes and Data Modification&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Another downside to using an index is the performance implication on data modification statements. Any time a query modifies the data in a table (INSERT, UPDATE, or DELETE), the database needs to update all of the indexes where data has changed. As we discussed earlier, indexing can help the database during data modification statements by allowing the database to quickly locate the records to modify, however, we now caveat the discussion with the understanding that providing too many indexes to update can actually hurt the performance of data modifications.&lt;br /&gt;&lt;br /&gt;This leads to a delicate balancing act when tuning the database for performance.&lt;br /&gt;In decision support systems and data warehouses, where information is stored for reporting purposes, data remains relatively static and report generating queries outnumber data modification queries. In these types of environments, heavy indexing is commonplace in order to optimize the reports generated. In contrast, a database used for transaction processing will see many records added and updated. These types of databases will use fewer indexes to allow for higher throughput on inserts and updates.&lt;br /&gt;&lt;br /&gt;Every application is unique, and finding the best indexes to use for a specific application usually requires some help from the optimization tools offered by many database vendors. SQL Server 2000 and Access include the Profiler and Index Tuning Wizard tools to help tweak performance.&lt;br /&gt;&lt;br /&gt;Now we have enough information to understand why indexes are useful and where indexes are best applied. It is time now to look at the different options available when creating an index and then address some common rules of thumb to use when planning the indexes for your database.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Clustered Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Earlier in the article we made an analogy between a database index and the index of a book. A book index stores words in order with a reference to the page numbers where the word is located. This type of index for a database is a nonclustered index; only the index key and a reference are stored. In contrast, a common analogy for a clustered index is a phone book. A phone book still sorts entries into alphabetical order. The difference is, once we find a name in a phone book, we have immediate access to the rest of the data for the name, such as the phone number and address.&lt;br /&gt;&lt;br /&gt;For a clustered index, the database will sort the table's records according to the column (or columns) specified by the index. A clustered index contains all of the data for a table in the index, sorted by the index key, just like a phone book is sorted by name and contains all of the information for the person inline. The nonclustered indexes created earlier in the chapter contain only the index key and a reference to find the data, which is more like a book index. You can only create one clustered index on each table.&lt;br /&gt;&lt;br /&gt;In the diagram below we have a search using a clustered index on the UnitPrice column of the Products table. Compare this diagram to the previous diagram with a regular index on UnitPrice. Although we are only showing three columns from the Products table, all of the columns are present and notice the rows are sorted into the order of the index, there is no reference to follow from the index back to the data. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLQAM2wQ47I/AAAAAAAACXM/BNgkIPMsDCI/s1600-h/INDEXClustered.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_tQtVPd7FlX4/SLQAM2wQ47I/AAAAAAAACXM/NKnJ9MqXelA/s400-R/INDEXClustered.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;A clustered index is the most important index you can apply to a table. If the database engine can use a clustered index during a query, the database does not need to follow references back to the rest of\ the data, as happens with a nonclustered index. The result is less work for the database, and consequently, better performance for a query using a clustered index.&lt;br /&gt;&lt;br /&gt;To create a clustered index, simply select the Create As CLUSTERED checkbox in the dialog box we used at the beginning of the chapter. The SQL syntax for a clustered index simply adds a new keyword to the CREATE INDEX command, as shown below:&lt;br /&gt;&lt;br /&gt;CREATE CLUSTERED INDEX IDX_SupplierID ON Products(SupplierID) &lt;br /&gt;&lt;br /&gt;Most of the tables in the Northwind database already have a clustered index defined on a table. Since we can only have one clustered index per table, and the Products table already has a clustered index (PK_Products) on the primary key (ProductId), the above command should generate the following error: &lt;br /&gt;&lt;br /&gt;Cannot create more than one clustered index on table 'Products'. &lt;br /&gt;Drop the existing clustered index 'PK_Products' before creating another. &lt;br /&gt;As a general rule of thumb, every table should have a clustered index. If you create only one index for a table, use a clustered index. Not only is a clustered index more efficient than other indexes for retrieval operations, a clustered index also helps the database efficiently manage the space required to store the table. &lt;br /&gt;&lt;br /&gt;In SQL Server, creating a primary key constraint will automatically create a clustered index (if none exists) using the primary key column as the index key. &lt;br /&gt;Sometimes it is better to use a unique nonclustered index on the primary key column, and place the clustered index on a column used by more queries. For example, if the majority of searches are for the price of a product instead of the primary key of a product, the clustered index could be more effective if used on the price field. A clustered index can also be a UNIQUE index. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;A Disadvantage to Clustered Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If we update a record and change the value of an indexed column in a clustered index, the database might need to move the entire row into a new position to keep the rows in sorted order. This behavior essentially turns an update query into a DELETE followed by an INSERT, with an obvious decrease in performance. A table's clustered index can often be found on the primary key or a foreign key column, because key values generally do not change once a record is inserted into the database.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Composite Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A composite index is an index on two or more columns. Both clustered and nonclustered indexes can be composite indexes. Composite indexes are especially useful in two different circumstances. First, you can use a composite index to cover a query. Secondly, you can use a composite index to help match the search criteria of specific queries. We will go onto more detail and give examples of these two areas in the following sections&lt;br /&gt;&lt;br /&gt;Covering Queries with an Index&lt;br /&gt;&lt;br /&gt;Earlier in the article we discussed how an index, specifically a nonclustered index, contains only the key values and a reference to find the associated row of data. However, if the key value contains all of the information needed to process a query, the database never has to follow the reference and find the row; it can simply retrieve the information from the index and save processing time. This is always a benefit for clustered indexes.&lt;br /&gt;As an example, consider the index we created on the Products table for UnitPrice. The database copied the values from the UnitPrice column and sorted them into an index. If we execute the following query, the database can retrieve all of the information for the query from the index itself. &lt;br /&gt;&lt;br /&gt;SELECT UnitPrice FROM Products ORDER BY UnitPrice &lt;br /&gt;&lt;br /&gt;We call these types of queries covered queries, because all of the columns requested in the output are contained in the index itself. A clustered index, if selected for use by the query optimizer, always covers a query, since it contains all of the data in a table.&lt;br /&gt;&lt;br /&gt;For the following query, there are no covering indexes on the Products table.&lt;br /&gt;&lt;br /&gt;SELECT ProductName, UnitPrice FROM Products ORDER BY UnitPrice &lt;br /&gt;&lt;br /&gt;This is because although the database will use the index on UnitPrice to avoid sorting records, it will need to follow the reference in each index entry to find the associated row and retrieve the product name. By creating a composite index on two columns (ProductName and UnitPrice), we can cover this query with the new index.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Matching Complex Search Criteria&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;For another way to use composite indexes, let's take a look at the OrderDetails table of Northwind. There are two key values in the table (OrderID and ProductID); these are foreign keys, referencing the Orders and Products tables respectively. There is no column dedicated for use as a primary key; instead, the primary key is the combination of the columns OrderID and ProductID.&lt;br /&gt;The primary key constraint on these columns will generate a composite index, which is unique of course. The command the database would use to create the index looks something like the following: &lt;br /&gt;&lt;br /&gt;CREATE UNIQUE CLUSTERED INDEX PK_Order_Details &lt;br /&gt;ON [Order Details] (OrderID, ProductID) &lt;br /&gt;&lt;br /&gt;The order in which columns appear in a CREATE INDEX statement is significant. The primary sort order for this index is OrderID. When the OrderID is the same for two or more records, the database will sort this subset of records on ProductID.&lt;br /&gt;The order of columns determines how useful the index is for a query. Consider the phone book sorted by last name then first name. The phone book makes it easy to find all of the listings with a last name of Smith, or all of the listings with a last name of Jones and a first name of Lisa, but it is difficult to find all listings with a first name of Gary without scanning the book page by page.&lt;br /&gt;Likewise, the composite index on Order Details is useful in the following two queries:&lt;br /&gt;&lt;br /&gt;SELECT * FROM [Order Details] WHERE OrderID = 11077 &lt;br /&gt;&lt;br /&gt;SELECT * FROM [Order Details] WHERE OrderID = 11077 AND ProductID = 13&lt;br /&gt;&lt;br /&gt;However, the following query cannot take advantage of the index we created since ProductID is the second part of the index key, just like the first name field in a phone book.&lt;br /&gt;&lt;br /&gt;SELECT * FROM [Order Details] WHERE ProductID = 13&lt;br /&gt;&lt;br /&gt;In this case, ProductID is a primary key, however, so an index does exist on the ProductID column for the database to use for this query.&lt;br /&gt;Suppose the following query is the most popular query executed by our application, and we decided we needed to tune the database to support it.&lt;br /&gt;&lt;br /&gt;SELECT ProductName, UnitPrice FROM Products ORDER BY UnitPrice &lt;br /&gt;&lt;br /&gt;We could create the following index to cover the query. Notice we have specified two columns for the index: UnitPrice and ProductName (making the index a composite index):&lt;br /&gt;&lt;br /&gt;CREATE INDEX IX_UnitPrice_ProductName ON Products(UnitPrice, ProductName) &lt;br /&gt;&lt;br /&gt;While covered queries can provide a performance benefit, remember there is a price to pay for each index we add to a table, and we can also never cover every query in a non-trivial application.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Additional Index Guidelines&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Choosing the correct columns and types for an index is another important step in creating an effective index. In this section, we will talk about two main points, namely short index keys and selective indexes (we'll explain what selective indexes are in just a moment).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Keep Index Keys Short&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The larger an index key is, the harder a database has to work to use the index. For instance, an integer key is smaller in size then a character field for holding 100 characters. In particular, keep clustered indexes as short as possible.&lt;br /&gt;&lt;br /&gt;There are several approaches to keeping an index key short. First, try to limit the index to as few columns as possible. While composite indexes are useful and can sometimes optimize a query, they are also larger and cause more disk reads for the database. Secondly, try to choose a compact data type for an index column, based on the number of bytes required for each data type. Integer keys are small and easy for the database to compare. In contrast, strings require a character-by-character comparison.&lt;br /&gt;As a rule of thumb, try to avoid using character columns in an index, particularly primary key indexes. Integer columns will always have an advantage over character fields in ability to boost the performance of a query.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Distinct Index Keys&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The most effective indexes are the indexes with a small percentage of duplicated values. Think of having a phone book for a city where 75% of the population has the last name of Smith. A phone book in this area might be easier to use if the entries were sorted by the resident's first names instead. A good index will allow the database to disregard as many records as possible during a search.&lt;br /&gt;An index with a high percentage of unique values is a selective index. Obviously, a unique index is the most selective index of all, because there are no duplicate values. SQL Server will track statistics for indexes and will know how selective each index is. The query optimizer utilizes these statistics when selecting the best index to use for a query.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Maintaining Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In addition to creating an index, we'll need to view existing indexes, and sometimes delete or rename them. This is part of the ongoing maintenance cycle of a database as the schema changes, or even naming conventions change.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;View Existing Indexes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A list of all indexes on a table is available in the dialog box we used to create an index. Click on the Selected index drop down control and scroll through the available indexes.&lt;br /&gt;There is also a stored procedure named sp_helpindex. This stored procedure gives all of the indexes for a table, along with all of the relevant attributes. The only input parameter to the procedure is the name of the table, as shown below.&lt;br /&gt;&lt;br /&gt;EXEC sp_helpindex Customers &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Rename an Index&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We can also rename any user created object with the sp_rename stored procedure, including indexes. The sp_rename procedure takes, at a minimum, the current name of the object and the new name for the object. For indexes, the current name must include the name of the table, a dot separator, and the name of the index, as shown below: &lt;br /&gt;&lt;br /&gt;EXEC sp_rename 'Products.IX_UnitPrice', 'IX_Price'&lt;br /&gt;&lt;br /&gt;This will change the name of the IX_UnitPrice index to IX_Price.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Delete an Index&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;It is a good idea to remove an index from the database if the index is not providing any benefit. For instance, if we know the queries in an application are no longer searching for records on a particular column, we can remove the index. Unneeded indexes only take up storage space and diminish the performance of modifications. You can remove most indexes with the Delete button on the index dialog box, which we saw earlier. The equivalent SQL command is shown below.&lt;br /&gt;DROP Index Products.IX_Price &lt;br /&gt;&lt;br /&gt;Again, we need to use the name of the table and the name of the index, with a dot separator. Some indexes are not so easy to drop, namely any index supporting a unique or primary key constraint. For example, the following command tries to drop the PK_Products index of the Products table. &lt;br /&gt;&lt;br /&gt;DROP INDEX Products.PK_Products &lt;br /&gt;&lt;br /&gt;Since the database uses PK_Products to enforce a primary key constraint on the Products table, the above command should produce the following error.&lt;br /&gt;An explicit DROP INDEX is not allowed on index 'Products.PK_Products'. &lt;br /&gt;It is being used for PRIMARY KEY constraint enforcement. &lt;br /&gt;&lt;br /&gt;Removing a primary key constraint from a table is a redesign of the table, and requires careful thought. It makes sense to know the only way to achieve this task is to either drop the table and use a CREATE TABLE command to recreate the table without the index, or to use the ALTER TABLE command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-3272722137690910143?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/3272722137690910143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-server-indexing-tutorial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3272722137690910143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3272722137690910143'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-server-indexing-tutorial.html' title='SQL Server INDEXING Tutorial'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_tQtVPd7FlX4/SLP3Htjm_dI/AAAAAAAACW0/KqIERlIQn1E/s72-Rc/INDEX12.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-5194685393987701212</id><published>2008-08-17T22:29:00.000-07:00</published><updated>2009-06-14T04:55:01.871-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Date Search'/><title type='text'>Searching for Dates and Times in SQL Server ??</title><content type='html'>Before you can effectively query date/time (or temporal) data, you have to know something about how date/time values are stored. SQL Server supports two date/time data types: datetime and smalldatetime. The difference between the two is the amount of storage used. Datetime uses 8 bytes of storage, while smalldatetime uses only 4 bytes. For this reason, datetime can represent date/time values within a wider range and with more precision than smalldatetime. These differences are summarized in the table below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="1" cellpadding="2" cellspacing="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="background-color: white; font-size: x-small;"&gt;&lt;b&gt;Type&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="background-color: white; font-size: x-small;"&gt;&lt;b&gt;Minimum&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="background-color: white; font-size: x-small;"&gt;&lt;b&gt;Maximum&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="background-color: white; font-size: x-small;"&gt;&lt;b&gt;Precision&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;datetime&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;Jan 1, 1753&lt;br /&gt;midnight&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;Dec 31, 9999&lt;br /&gt;23:59:59.997&lt;br /&gt;(0.003 seconds until midnight)&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;To the nearest&lt;br /&gt;3.33 milliseconds&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;smalldatetime&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;Jan 1, 1900&lt;br /&gt;midnight&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;Jun 6, 2079&lt;br /&gt;23:59&lt;br /&gt;(1 minute until midnight)&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-small;"&gt;To the nearest&lt;br /&gt;minute&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;Both datetime and smalldatetime represent the date and time as a value that’s equal to the number of days in relationship to a base date. In SQL Server, that base date is midnight on January 1, 1900. As you can see in the table, the smalldatetime type can only represent dates from this base date on. In contrast, the datetime type can also represent dates that are before January 1, 1900. To do that, it stores those values as negative numbers.&lt;br /&gt;To visualize how date/time values are stored, you can think of them as consisting of two parts. The integer portion represents the number of whole days since January 1, 1900. The fractional portion represents the fraction of a day that’s passed since midnight. For example, the date/time value representing noon on January 4, 1900 is stored as 3.5. In this case, 3 represents three full days since the base date and 0.5 represents one half of a day between midnight and noon. To see this, submit the following query:&lt;br /&gt;&lt;br /&gt;&lt;span style="background-color: #ffff99; font-family: courier new,courier,mono;"&gt;SELECT CAST(CAST('1900-01-04 12:00' AS datetime) AS float)&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="txtplain1"&gt;Datetime and smalldatetime are like the floating-point data types, float and real, in that they’re approximate numerics. That means the value retrieved from SQL Server may be different from the value that was originally stored. For example, if you store the expression 10/3.0 in a column of data type float, you’ll retrieve a value 3.3333330000000001. Although this is a reasonable representation of ten thirds, it’s not exact since it’s rounded past the 6th digit. In fact, if you add three such values together, you get 9.9999990000000007, not 10. Of course, most programmers understand this as a rounding error. And it’s a persistent problem for all digital computers, not just those running SQL Server. Still, you need to be aware of it as you code search conditions. In contrast, when working with exact numeric data, the value retrieved from SQL Server is exactly the value that was originally stored. For example, if you store 10/3.0 in a column of data type int, it’s stored as 3 and retrieved as 3. In this case, SQL Server implicitly casts the result of the expression as a real value, 3.333333. Then, SQL Server implicitly casts 3.333333 as an integer because it’s being stored in a column of type int. Although this is still a rounding error, it occurs before the value is stored, not as a result of the physical limitations of computer storage. In other words, the error was introduced by using the wrong data type, not by the inherent limitation of the data type itself. Since the system always returns the same value as was stored, the data type is exact.&lt;br /&gt;Now, to see how this affects date/time values, consider the date and time value for 8:00AM on January 4, 1900. As you saw above, noon on this day is stored as 3.5, or halfway through the fourth day. In contrast, 8:00AM is one third of the way through the day, so its representation will be approximate. To see this for yourself, submit the following query:&lt;br /&gt;&lt;br /&gt;&lt;span style="background-color: #ffff99; font-family: courier new,courier,mono;"&gt;SELECT CAST(CAST('1900-01-04 08:00' AS datetime) AS float)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You’ll get the following result:&lt;br /&gt;&lt;b&gt;&lt;span style="font-family: courier new,courier,mono;"&gt;3.3333333333333335&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;But if you submit this query:&lt;br /&gt;&lt;br /&gt;&lt;span style="background-color: #ffff99; font-family: courier new,courier,mono;"&gt;SELECT CAST(3.3333333 AS datetime), CAST(3.3333334 AS datetime)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you’ll get the following results:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-family: courier new,courier,mono;"&gt;1900-01-04 07:59:59.997&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1900-01-04 08:00:00.003&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As you can see, these three values are all quite close. In fact, they’re close enough to be considered 8:00AM for most applications. However, in a search condition based on a single value, such as:&lt;br /&gt;&lt;br /&gt;&lt;span style="background-color: #ffff99; font-family: courier new,courier,mono;"&gt;WHERE (DTValue = '1900-01-04 08:00')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;you’d only match those rows where the stored value exactly matches 3.3333333333333335.&lt;br /&gt;&lt;br /&gt;&lt;span class="txtplain1"&gt;SQL Server doesn’t provide data types for storing just the date or just the time. So if you store a date/time value without an explicit time, the fractional portion of the value is set to zero. This represents midnight as 00:00:00. Similarly, if you store a date/time value without an explicit date, the integer portion of the value is set to zero. This represents the date January 1, 1900. To see this, submit the following query:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="txtplain1"&gt;&lt;span style="background-color: #ffff99; font-family: courier new,courier,mono;"&gt;SELECT CAST('1900-01-04' AS datetime), CAST('10:00' AS datetime)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;which returns the following result:&lt;br /&gt;&lt;b&gt;&lt;span style="font-family: courier new,courier,mono;"&gt;1900-01-04 00:00:00.000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1900-01-01 10:00:00.000&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Whether you can ignore the date or the time component when you query a date/time column depends on how the column has been designed and used.&lt;/span&gt; &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-5194685393987701212?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/5194685393987701212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/searching-for-dates-and-times-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/5194685393987701212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/5194685393987701212'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/searching-for-dates-and-times-in-sql.html' title='Searching for Dates and Times in SQL Server ??'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-1051459334392633059</id><published>2008-08-16T04:57:00.000-07:00</published><updated>2009-06-14T04:55:01.880-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Views'/><title type='text'>Views in SQL Server</title><content type='html'>&lt;p&gt;A view is a virtual table that consists of columns from one or more tables. Though it is similar to a table, it is stored in the database. It is a query stored as an object. Hence, a view is an object that derives its data from one or more tables. These tables are referred to as base or underlying tables.&lt;/p&gt; &lt;p&gt;Once you have defined a view, you can reference it like any other table in a database.&lt;/p&gt; &lt;p&gt;A view serves as a security mechanism. This ensures that users are able to retrieve and modify only the data seen by them. Users cannot see or access the remaining data in the underlying tables. A view also serves as a mechanism to simplify query execution. Complex queries can be stored in the form as a view, and data from the view can be extracted using simple queries.&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;Example&lt;/span&gt; &lt;p&gt;Consider the Publishers table below. If you want users to see only two columns in the table, you can create a view called vwPublishers that will refer to the Publishers table and the two columns required. You can grant Permissions to users to use the view and revoke Permissions from the base Publishers table. This way, users will be able to view only the two columns referred to by the view. They will not be able to query on the Publishers table.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Publishers&lt;/strong&gt;&lt;/p&gt; &lt;table border="1" cellpadding="2" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;Publd&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;PubName&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;City&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;State&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Country&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;0736&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;New Moon Books&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Boston&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;MA&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;USA&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;0877&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Binnet &amp;amp; Hardly&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Washington&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;DC&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;USA&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;1389&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Algodata Infosystems&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Berkeley&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;CA&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;USA&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;1622&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Five Lakes Publishing&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Chicago&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;IL&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;USA&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;strong&gt;VW Publishers&lt;/strong&gt;&lt;/p&gt; &lt;table border="1" cellpadding="2" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;Publd&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;PubName&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;0736&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;New Moon Books&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;0877&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Binnet &amp;amp; Hardly&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;1389&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Algodata Infosystems&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;1622&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Five Lakes Publishing&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Views ensure the security of data by restricting access to the following data:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Specific rows of the tables.&lt;/li&gt;&lt;li&gt;Specific columns of the tables.&lt;/li&gt;&lt;li&gt;Specific rows and columns of the tables.&lt;/li&gt;&lt;li&gt;Rows fetched by using joins.&lt;/li&gt;&lt;li&gt;Statistical summary of data in a given tables.&lt;/li&gt;&lt;li&gt;Subsets of another view or a subset of views and tables.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Some common examples of views are:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A subset of rows or columns of a base table.&lt;/li&gt;&lt;li&gt;A union of two or more tables.&lt;/li&gt;&lt;li&gt;A join of two or more tables.&lt;/li&gt;&lt;li&gt;A statistical summary of base tables.&lt;/li&gt;&lt;li&gt;A subset of another view, or some combination of views and base table.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Creating Views&lt;/span&gt;&lt;br /&gt;&lt;p&gt;A view can be created by using the CREATE VIEW statement.&lt;/p&gt; &lt;h3&gt;Syntax&lt;/h3&gt; &lt;p class="textCode"&gt;CREATE VIEW view_name&lt;br /&gt;[(column_name[,column_name]….)]&lt;br /&gt;[WITH ENCRYPTION]&lt;br /&gt;AS select_statement [WITH CHECK OPTION]&lt;/p&gt; &lt;p&gt;Where:&lt;/p&gt; &lt;p&gt;view_name specifies the name of the view and must follow the rules for identifiers.&lt;/p&gt; &lt;p&gt;column_name specifies the name of the column to be used in view. If the column_name option is not specified, then the view is created with the same columns as specified in the select_statement.&lt;/p&gt; &lt;p&gt;WITH ENCRYPTION encrypts the text for the view in the syscomments table.&lt;/p&gt; &lt;p&gt;AS specifies the actions that will be performed by the view.&lt;/p&gt; &lt;p&gt;select_statement specifies the SELECT Statement that defines a view. The view may use the data contained in other views and tables.&lt;/p&gt; &lt;p&gt;WITH CHECK OPTION forces the data modification statements to fulfill the criteria given in the SELECT statement defining the view. It also ensures that the data is visible after the modifications are made permanent.&lt;/p&gt; &lt;p&gt;The restrictions imposed on views are as follows:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A view can be created only in the current database.&lt;/li&gt;&lt;li&gt;The name of a view must follow the rules for identifiers and must not be the same as that of the base table.&lt;/li&gt;&lt;li&gt;A view can be created only if there is a SELECT permission on its base table.&lt;/li&gt;&lt;li&gt;A SELECT INTO statement cannot be used in view declaration statement.&lt;/li&gt;&lt;li&gt;A trigger or an index cannot be defined on a view.&lt;/li&gt;&lt;li&gt;The CREATE VIEW statement cannot be combined with other SQL statements in a single batch.&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;Example&lt;/h3&gt; &lt;p class="textCode"&gt;CREATE VIEW vwCustomer&lt;br /&gt;AS&lt;br /&gt;SELECT CustomerId, Company Name, Phone&lt;br /&gt;FROM Customers&lt;/p&gt; &lt;p&gt;Creates a view called vwCustomer. Note that the view is a query stored as an object. The data is derived from the columns of the base table Customers.&lt;/p&gt; &lt;p&gt;You use the view by querying the view like a table.&lt;/p&gt; &lt;p class="textCode"&gt;SELECT *FROM vwCUSTOMER&lt;/p&gt; &lt;p&gt;The output of the SELECT statement is:&lt;/p&gt; &lt;table border="1" cellpadding="2" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr valign="top"&gt; &lt;td width="75"&gt; &lt;p&gt;CustomerId&lt;/p&gt;&lt;/td&gt; &lt;td width="160"&gt; &lt;p&gt;Company Name&lt;/p&gt;&lt;/td&gt; &lt;td width="82"&gt; &lt;p&gt;Phone&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;ALFKI&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Alfreds Futterkiste&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;030-0074321&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr valign="top"&gt; &lt;td&gt; &lt;p&gt;ANTON&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;Antonio Moreno Taqueria&lt;/p&gt;&lt;/td&gt; &lt;td&gt; &lt;p&gt;(5)555-3932&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;(91 rows affected)&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;Getting Informations Related to Views&lt;br /&gt;&lt;/span&gt; &lt;p&gt;SQL Server stores information on the view in the following system tables:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;SYSOBJECTS — stores the name of the view.&lt;/li&gt;&lt;li&gt;SYSCOLUMNS — stores the names of the columns defined in the view.&lt;/li&gt;&lt;li&gt;SYSDEPENDS — stores information on the view dependencies.&lt;/li&gt;&lt;li&gt;SYSCOMMENTS — stores the text of the view definition.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;There are also certain system-stored procedures that help retrieve information on views. The sp_help system-stored procedure displays view-related information. It displays the view definition, provided the name of the view is given as its parameter.&lt;/p&gt; &lt;h3&gt;Example&lt;/h3&gt; &lt;p class="textCode"&gt;Sp_helptext vwCustomer&lt;/p&gt; &lt;p&gt;Displays the definition of the vwCustomer view.&lt;/p&gt; &lt;h3&gt;Note&lt;/h3&gt; &lt;p&gt;If a view is created with the WITH ENCRYPTION option, it cannot view the sp_helptext system-stored procedure.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-1051459334392633059?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/1051459334392633059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/views-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1051459334392633059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1051459334392633059'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/views-in-sql-server.html' title='Views in SQL Server'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-7474961880122851033</id><published>2008-08-15T02:48:00.000-07:00</published><updated>2009-06-14T04:55:01.887-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Stored Procedures'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL Server Stored Procedures A Small Tutorial</title><content type='html'>&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Stored procedures are extremely useful objects.&amp;nbsp; Not only do they store T/SQL scripts for later execution, but they also provide us with an extremely important security barrier between the user interface and the database.&amp;nbsp; The security barrier is used to prevent the users from needing SELECT, INSERT, UPDATE and/or DELETE rights directly to the database tables and views.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This is done through what is called permissions chaining.&amp;nbsp; When a user has rights to execute a stored procedure they are given temporary rights to use the table objects within the procedures which are used by the table.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Creating stored procedures is very easy.&amp;nbsp; Take your Transact SQL code and put it below the CREATE PROCEDURE command, and end the batch.&amp;nbsp; Like all other database objects the name of the stored procedure must be unique within the schema (or owner for SQL 2000 and below).&amp;nbsp; As an example lets create a stored procedure which returns the names of all the tables in the current database.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;div style="color: blue;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;CREATE PROCEDURE ShowTables AS&lt;br /&gt;SELECT schema_name(schema_id), name&lt;br /&gt;FROM sys.tables&lt;br /&gt;GO&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;&amp;nbsp; &lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;As you can see the basic syntax is very simple.&amp;nbsp; To run this stored procedure we simply run the stored procedure name.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;div style="color: blue;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;exec ShowTables&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;&amp;nbsp; &lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;You can add in input parameters to handle filtering, or which would need to be inserted into a table.&amp;nbsp; An input parameter is simply a variable which you set when you run the procedure.&amp;nbsp; You can access the value of the input parameter within the stored procedure as you would any other variable.&amp;nbsp; Let’s look at the same procedure but this time we want to filter the tables by the first letter.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;CREATE PROCEDURE ShowTables&lt;br /&gt;&amp;nbsp; @FilterChar NVARCHAR(2)&lt;br /&gt;AS&lt;br /&gt;SET @FilterChar = @FilterChar + ‘%’&lt;br /&gt;SELECT schema_name(schema_id), name&lt;br /&gt;FROM sys.tables&lt;br /&gt;WHERE name LIKE @FilterChar&lt;br /&gt;GO&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;&amp;nbsp; &lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In this example as you can see we take the input parameter, and add the % wild card, then use the variable to filter down the records to see only the records which start with the character we supply.&amp;nbsp; Running the stored procedure with an input parameter is just as easy.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;exec ShowTables @FilterChar=N'C'&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;&amp;nbsp; &lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We can also use output parameters to get values back from the stored procedures.&amp;nbsp; Output parameters are used basically in the same way that input parameters are, however you add the OUTPUT keyword after the parameter.&amp;nbsp; Within the stored procedure simply set the output variable to the value you want it to return to the calling code.&amp;nbsp; This can be done anywhere within the stored procedure, as long as&amp;nbsp;the variable still holds the value when the stored procedure has completed it’s execution the value will be returned to the calling code.&amp;nbsp; First lets look at the code to create the stored procedure.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: x-small;"&gt;CREATE PROCEDURE ShowTables&lt;br /&gt;&amp;nbsp; @FilterChar NVARCHAR(2),&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp;@RowCount INT OUTPUT&lt;br /&gt;AS&lt;br /&gt;SET @FilterChar = @FilterChar + ‘%’&lt;br /&gt;SELECT schema_name(schema_id), name&lt;br /&gt;FROM sys.tables&lt;br /&gt;WHERE name LIKE @FilterChar&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;SET @RowCount = @@ROWCOUNT&lt;br /&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We run the stored procedure in much the same way we do with the input parameter.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;DECLARE @RowCount INT&lt;br /&gt;exec ShowTables @FilterChar=N’C', @RowCount=@RowCount OUTPUT&lt;br /&gt;SELECT @RowCount&lt;/span&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In this case we are simply returning the row count as a second record set, but you’ll get the basic idea.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;As I wrote earlier you can add records to a table with the stored procedure.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;CREATE PROCEDURE InsertTable&lt;br /&gt;&amp;nbsp; @Id INT,&lt;br /&gt;&amp;nbsp; @Value VARCHAR(20)&lt;br /&gt;AS &lt;/code&gt;&lt;code&gt;INSERT INTO SomeTable&lt;br /&gt;(Id, Value)&lt;br /&gt;VALUE&lt;br /&gt;(@Id, @Value)&lt;br /&gt;GO&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;&amp;nbsp; &lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;As you can see it’s a very basic method.&amp;nbsp; It’s a regular insert statement with the parameters passed to it.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-7474961880122851033?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/7474961880122851033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-server-stored-procedures-small.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7474961880122851033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7474961880122851033'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-server-stored-procedures-small.html' title='SQL Server Stored Procedures A Small Tutorial'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-3333109703602002922</id><published>2008-08-13T20:35:00.000-07:00</published><updated>2009-06-14T04:55:01.895-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql case statement'/><category scheme='http://www.blogger.com/atom/ns#' term='select case sql'/><category scheme='http://www.blogger.com/atom/ns#' term='sql case when'/><category scheme='http://www.blogger.com/atom/ns#' term='case in sql'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server case'/><category scheme='http://www.blogger.com/atom/ns#' term='select case'/><title type='text'>SQL case statement : Using the CASE Statement in a SQL SELECT Clause</title><content type='html'>SQL Server provides a mechanism for returning different values in a SELECT clause based on Boolean conditions: the CASE statement. This statement resembles Visual Basics Select Case statement. &lt;p&gt; The SQL CASE statement has WHEN, THEN, and ELSE clauses along with an END terminator. The syntax is: &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;CASE [expression]&lt;br /&gt;WHEN [value | Boolean expression] THEN [return value]&lt;br /&gt;[ELSE [return value]]&lt;br /&gt;END&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;The [expression] is optional and contains a table column or a variable. When you specify [expression] directly after the CASE, you must populate the [value] parameter in the WHEN clause: &lt;pre&gt;&lt;code&gt;&lt;br /&gt;DECLARE @TestVal int&lt;br /&gt;SET @TestVal = 3&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;CASE @TestVal&lt;br /&gt; WHEN 1 THEN 'First'&lt;br /&gt; WHEN 2 THEN 'Second'&lt;br /&gt; WHEN 3 THEN 'Third'&lt;br /&gt; ELSE 'Other'&lt;br /&gt;END&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;SQL Server compares this value to the expression and when the values match, it returns the THEN clauses [return value]. If none of the WHEN clauses equates to true, SQL Server returns the [return value] in the optional ELSE clause. If the ELSE clause is omitted and no value is matched, NULL is returned. &lt;p&gt;If you dont specify [expression], you must include the [Boolean expression] in the WHEN clause. This can contain any valid Boolean expression SQL Server allows: &lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;DECLARE @TestVal int&lt;br /&gt;SET @TestVal = 5&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;CASE&lt;br /&gt; WHEN @TestVal &lt;=3 THEN 'Top 3'   ELSE 'Other'  END &lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-3333109703602002922?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/3333109703602002922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-case-statement-using-case-statement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3333109703602002922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/3333109703602002922'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-case-statement-using-case-statement.html' title='SQL case statement : Using the CASE Statement in a SQL SELECT Clause'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-563473344194201076</id><published>2008-08-12T22:20:00.000-07:00</published><updated>2009-06-14T04:55:01.902-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LEFT JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='OUTER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='INNER JOIN'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL JOINS TUTORIAL</title><content type='html'>This is just a basic overview to give you an idea the data a particular join will return to you. This is not a technical discussion - just concepts.&lt;br /&gt;&lt;br /&gt;We will start with just an empty diagram:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJvgeWvbVI/AAAAAAAACQQ/w00MyZ2DfIk/s1600-h/basicvenn.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJvgeWvbVI/AAAAAAAACQQ/w00MyZ2DfIk/s400/basicvenn.png" alt="" id="BLOGGER_PHOTO_ID_5233868320652881234" border="0" /&gt;&lt;/a&gt;&lt;p&gt;The T1 circle represents all the records in table 1. The T2 circle represents all the records in table 2. Notice how there is a bit of overlap of the 2 circles in the middle. Simple right?&lt;/p&gt; &lt;p&gt;I will use red to signify the records that will be returned by a particular join.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;INNER JOIN&lt;/strong&gt;&lt;br /&gt;An inner join only returns those records that have “matches” in both tables. So for every record returned in T1 - you will also get the record linked by the foreign key in T2. In programming logic - think in terms of AND.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tQtVPd7FlX4/SKJv5moAuFI/AAAAAAAACQY/BlDxY2iquFs/s1600-h/venn1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tQtVPd7FlX4/SKJv5moAuFI/AAAAAAAACQY/BlDxY2iquFs/s400/venn1.png" alt="" id="BLOGGER_PHOTO_ID_5233868752369530962" border="0" /&gt;&lt;/a&gt;&lt;strong&gt;OUTER JOIN&lt;/strong&gt;&lt;br /&gt;An outer join is the inverse of the inner join. It only returns those records not in T1 and T2. “Give me the records that DON’T have a match.” In programming logic - think in terms of NOT AND.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_tQtVPd7FlX4/SKJwZaLA4YI/AAAAAAAACQg/d1H8WRuZEa4/s1600-h/outervenn.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_tQtVPd7FlX4/SKJwZaLA4YI/AAAAAAAACQg/d1H8WRuZEa4/s400/outervenn.png" alt="" id="BLOGGER_PHOTO_ID_5233869298782495106" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;LEFT JOIN&lt;/strong&gt;&lt;br /&gt;A left join returns all the records in the “left” table (T1) whether they have a match in the right table or not. &lt;/p&gt; &lt;p&gt;If, however, they do have a match in the right table - give me the “matching” data from the right table as well. If not - fill in the holes with null.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJwsw49IMI/AAAAAAAACQo/5_SZMvgJw9k/s1600-h/left_venn.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJwsw49IMI/AAAAAAAACQo/5_SZMvgJw9k/s400/left_venn.png" alt="" id="BLOGGER_PHOTO_ID_5233869631298281666" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It should be noted that the same thing is possible with a right join - most people just use a left one.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;LEFT OUTER JOIN&lt;/strong&gt;&lt;br /&gt;A left outer join combines the ideas behind a left join and an outer join. Basically - if you use a left outer join you will get the records in the left table that DO NOT have a match in the right table.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJxIFk40KI/AAAAAAAACQw/tR87UXYQoCw/s1600-h/leftOutervenn.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJxIFk40KI/AAAAAAAACQw/tR87UXYQoCw/s400/leftOutervenn.png" alt="" id="BLOGGER_PHOTO_ID_5233870100707725474" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Again it is noted that the same thing is possible with a right outer join - most people just use a left one.&lt;/p&gt; &lt;strong&gt;Theta JOIN&lt;/strong&gt;&lt;br /&gt;A theta join is the Cartesian product of the 2 tables and not normally what people are looking for - but what they sometimes get by mistake. How many of us have written a join similar to this only to get way more then we were ever expecting.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SELECT t1.*, t2.*&lt;br /&gt;  FROM table1 t1, table2 t2&lt;br /&gt;  WHERE t1.id = 5;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_tQtVPd7FlX4/SKJxjTi5hqI/AAAAAAAACQ4/ZALCxFygPbg/s1600-h/thetavenn.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_tQtVPd7FlX4/SKJxjTi5hqI/AAAAAAAACQ4/ZALCxFygPbg/s400/thetavenn.png" alt="" id="BLOGGER_PHOTO_ID_5233870568313947810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;So there you have the basic concepts of joins. Next time you need to use a join and have no clue what to do to get the data you need from the database, draw a picture. It may help you figure out what join to use.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-563473344194201076?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/563473344194201076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-joins-tutorial.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/563473344194201076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/563473344194201076'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-joins-tutorial.html' title='SQL JOINS TUTORIAL'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_tQtVPd7FlX4/SKJvgeWvbVI/AAAAAAAACQQ/w00MyZ2DfIk/s72-c/basicvenn.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-1448911579070571689</id><published>2008-08-12T21:59:00.000-07:00</published><updated>2009-06-14T04:55:01.909-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Interview Questions'/><title type='text'>SQL Interview Questions, Explanation of statements  SELECT ,INSERT, LIKE etc...</title><content type='html'>&lt;table align="center" cellspacing="1" style=""&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="heading"&gt;How would you find out the total number of rows in a table? &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;Use SELECT COUNT(*) ... in query&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you eliminate duplicate values in SELECT ?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Use SELECT DISTINCT ... in SQL query&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;How you insert records into a table &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;Using SQL INSERT statement&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you delete record from a table ?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Using DELETE statement&lt;br /&gt;Example : DELETE FROM EMP&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you select a row using indexes?  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Specify the indexed columns in the WHERE clause of query.&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you find the maximum value in a column?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Use SELECT MAX(...) .. in query&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you retrieve the first 5 characters of FIRSTNAME column of table EMP ?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results. Why?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Because SALARY is not declared to have NULLs and the employees for whom the&lt;br /&gt;salary is not known are also counted.&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;How do you concatenate the FIRSTNAME and LASTNAME from EMP table to give a complete name?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;SELECT FIRSTNAME || ‘ ‘ || LASTNAME FROM EMP&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What is UNION,UNION ALL in SQL?    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;UNION : eliminates duplicates&lt;br /&gt;UNION ALL: retains duplicates&lt;br /&gt;Both these are used to combine the results of different SELECT statements.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;Suppose I have five SQL SELECT statements connected by UNION/UNION ALL, how many times&lt;br /&gt;should I specify UNION to eliminate the duplicate rows?  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Once.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;In the WHERE clause what is BETWEEN and IN?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;BETWEEN supplies a range of values while IN supplies a list of values.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;Is BETWEEN inclusive of the range values specified?    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Yes.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What is 'LIKE' used for in WHERE clause? What are the wildcard characters?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;LIKE is used for partial string matches. ‘%’ ( for a string of any character ) &lt;br /&gt;and ‘_’ (for any single character ) are the two wild card characters.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;When do you use a LIKE statement?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;To do partial search e.g. to search employee by name, you need not specify &lt;br /&gt;the complete name; using LIKE, you can search for partial string matches.&lt;br /&gt;&lt;br /&gt;   Example SQL :  SELECT EMPNO FROM EMP &lt;br /&gt;                  WHERE EMPNAME LIKE 'RAMESH%'&lt;br /&gt;&lt;br /&gt;% is used to represent remaining all characters in the name.&lt;br /&gt;This query fetches all records contains RAMESH in six characters.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What do you accomplish by GROUP BY ... HAVING clause?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;GROUP BY partitions the selected rows on the distinct values of the column on &lt;br /&gt;which you group by. HAVING selects GROUPs which match the criteria specified&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;Consider the employee table with column PROJECT nullable. How can you get a list&lt;br /&gt;of employees   who are not assigned to any project?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;SQL  :  SELECT EMPNO &lt;br /&gt;        FROM EMP&lt;br /&gt;        WHERE PROJECT IS null;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What are the large objects supported by oracle and db2?  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Blob , Clob ( Binary Large Objects, Character Large Objects)&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What's the difference between a primary key and a unique key?    &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Primary key wont allow nulls, unique key allow nulls.&lt;br /&gt;Both Primary key and Unique key enforce the uniqueness of the column on which they are defined.&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What is a join and explain different types of joins?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;INNER JOIN&lt;br /&gt;OUTER JOIN&lt;br /&gt;LEFT OUTER JOIN&lt;br /&gt;RIGHT OUTER JOIN&lt;br /&gt;FULL OUTER JOIN&lt;br /&gt;INNER JOIN&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What is a self join?  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Joining two instances of a same table. &lt;br /&gt;Sample SQL  :  SELECT A.EMPNAME , B.EMPNAME &lt;br /&gt;               FROM EMP A, EMP B&lt;br /&gt;               WHERE A.MGRID = B.EMPID&lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;What is a transaction and ACID?   &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;font class="answer"&gt;&lt;pre&gt;Transaction - A transaction is a logicl unint of work. All steps must be commited or rolled back.&lt;br /&gt;ACID - Atomicity, Consistency, Isolation and Duralbility, these are properties of a transaction.&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td class="heading"&gt;  &lt;br /&gt;Materialized Query Tables in db2 ( This feature might not be available in oracle) ?  &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;     &lt;td&gt;&lt;pre&gt;&lt;font class="answer"&gt;Materialized Query Tables or MQTs are also known as automatic summary &lt;br /&gt;tables. A materialized query table (MQT) is a table whose definition is based upon the result of a &lt;br /&gt;query. The data that is contained in an MQT is derived from one or more tables on which the materialized &lt;br /&gt;query table definition is based.  MQT improve the query performance.  &lt;br /&gt;&lt;br /&gt;Sample SQL to creat MQT.&lt;br /&gt;&lt;br /&gt;CREATE TABLE CUSTOMER_ORDER AS &lt;br /&gt;(SELECT SUM(AMOUNT) AS TOTAL_SUM, &lt;br /&gt;TRANS_DT, &lt;br /&gt;STATUS &lt;br /&gt;FROM DB2INST2.CUSTOMER_ORDER &lt;br /&gt;WHERE TRANS_DT BETWEEN '1/1/2001' AND '12/31/2001' &lt;br /&gt;GROUP BY TRANS_DT, &lt;br /&gt;STATUS) &lt;br /&gt;DATA INITIALLY DEFERRED REFRESH DEFERRED; &lt;br /&gt; &lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-1448911579070571689?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/1448911579070571689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-interview-questions-explanation-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1448911579070571689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1448911579070571689'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2008/08/sql-interview-questions-explanation-of.html' title='SQL Interview Questions, Explanation of statements  SELECT ,INSERT, LIKE etc...'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-7123007806171919571</id><published>2007-07-31T00:02:00.000-07:00</published><updated>2009-06-18T03:50:11.549-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>Reading Excel Data From C#.NET: Problem With Data Types</title><content type='html'>&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br /&gt;While retrieving data from Excel using any scripting language like ASP.NET&lt;br /&gt;the data is retrieved from the Excel file, the data does not retrieve the correct/exact data type. The data type for each column is determined based on the values (scanning of rows by excel driver) of the first eight or 16 rows.&lt;br /&gt;&lt;br /&gt;The problem is due to the fact that Excel Driver scans the first eight or 16 rows, the format of the data (for each particular column) in the first eight rows should be the same for all the rows. If the data in the first eight rows is numeric or numbers and the next few rows is alphanumeric (characters and numbers) then these few rows would not be retrieved or not retrieved in the correct datatype.&lt;br /&gt;&lt;br /&gt;Eg: Say your database field or column (say weight) that can have values like&lt;br /&gt;&lt;br /&gt;1) 900,&lt;br /&gt;2) 900kgs,&lt;br /&gt;3) 900pounds.&lt;br /&gt;&lt;br /&gt;Then, if the first rows has values in numbers "900" and the following row(s) has values in alphanumeric (say 900kgs, 900pounds etc.,) then,&lt;br /&gt;&lt;br /&gt;Excel cannot retrieve these rows since the values are in alphanumeric and the Excel driver has already scanned the first row and identified the values might be in numeric so it will only read the nummeric data in that field.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Connection String:&lt;/em&gt;&lt;br /&gt;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePath;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1) "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.&lt;br /&gt;&lt;br /&gt;2) "IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.&lt;br /&gt;&lt;br /&gt;SQL syntax "SELECT * FROM [sheet1$]". I.e. excel worksheet name followed by a "$" and wrapped in "[" "]" brackets.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Important:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Check out the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel] located registry REG_DWORD "TypeGuessRows". &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;That's the key to not letting Excel use only the first &lt;strong&gt;8&lt;/strong&gt; rows to guess the columns data type. Set this value to &lt;strong&gt;0&lt;/strong&gt; to scan all rows. This might hurt performance.&lt;br /&gt;&lt;br /&gt;If the Excel workbook is protected by a password, you cannot open it for data access, even by supplying the correct password with your connection string. If you try, you receive the following error message: "Could not decrypt file."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-7123007806171919571?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/7123007806171919571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2007/07/reading-excel-data-from-cnet-problem.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7123007806171919571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/7123007806171919571'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2007/07/reading-excel-data-from-cnet-problem.html' title='Reading Excel Data From C#.NET: Problem With Data Types'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8244039807493704520.post-1357589210736092786</id><published>2007-07-30T23:11:00.000-07:00</published><updated>2009-06-14T04:55:01.922-07:00</updated><title type='text'>Welcome to Byte Your Head</title><content type='html'>Hi Friends,&lt;br /&gt;&lt;br /&gt;Welcome to Byte You Head blog spot area where we can discuss varity of funny problem arised in our day to day development life. Areas of our discussion will be on various platforms like NET, JAVA, PHP, Windows OS, LINUX,MySQL, SQL Server etc...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8244039807493704520-1357589210736092786?l=byteyourhead.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://byteyourhead.blogspot.com/feeds/1357589210736092786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://byteyourhead.blogspot.com/2007/07/welcome-to-byte-your-head.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1357589210736092786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8244039807493704520/posts/default/1357589210736092786'/><link rel='alternate' type='text/html' href='http://byteyourhead.blogspot.com/2007/07/welcome-to-byte-your-head.html' title='Welcome to Byte Your Head'/><author><name>anu</name><uri>http://www.blogger.com/profile/08578512326411922549</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
