Tuesday, March 4, 2008

Dot net interview questions

Sponsored links

1. What is .NET?That's difficult to sum up in a sentence. According to Microsoft, .NET is a "revolutionary new platform, built on open Internet protocols and standards, with tools and services that meld computing and communications in new ways".A more practical definition would be that .NET is a new environment for developing and running software applications, featuring ease of development of web-based services, rich standard run-time services available to components written in a variety of programming languages, and inter-language and inter-machine interoperability.Note that when the term ".NET" is used in this FAQ it refers only to the new .NET runtime and associated technologies. This is sometimes called the ".NET Framework". This FAQ does NOT cover any of the various other existing and new products/technologies that Microsoft are attaching the .NET name to (e.g. SQL Server.NET).2. Does .NET only apply to people building web-sites?No. If you write any Windows software (using ATL/COM, MFC, VB, or even raw Win32), .NET may offer a viablealternative (or addition) to the way you do things currently. Of course, if you do develop web sites, then .NET haslots to interest you - not least ASP.NET.3. When was .NET announced?Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had anumber of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.4. When was the first version of .NET released?The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.5. What platforms does the .NET Framework run on?The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home.The Mono project is attempting to implement the .NET framework on Linux.6. What languages does the .NET Framework support?MS provides compilers for C#, C++, VB and JScript. Other vendors have announced that they intend to develop .NET compilers for languages such as COBOL, Eiffel, Perl, Smalltalk and Python.7. Will the .NET Framework go through a standardisation process?From http://msdn.microsoft.com/net/ecma/: "On December 13, 2001, the ECMA General Assembly ratified the C# and common language infrastructure (CLI) specifications into international standards. The ECMA standards will be known as ECMA-334 (C#) and ECMA-335 (the CLI)."Basic terminology8. What is the CLR?CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC# article:Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection)Security model, Type system , All .NET base classes, Many .NET framework classes, Development, debugging, and profiling tools, Execution and code managementIL-to-native translators and optimizers
9. What is IL?IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.10. What is C#?C# is a new language designed by Microsoft to work with the .NET framework. In their "Introduction to C#" whitepaper, Microsoft describe C# as follows: "C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced C sharp) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++." Substitute 'Java' for 'C#' in the quote above, and you'll see that the statement still works pretty well :-).11. What does 'managed' mean in the .NET context?The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).Managed data: This is data that is allocated and de-allocated by the .NET runtime's garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.12. What is reflection?All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).Assemblies13. What is an assembly?An assembly is sometimes described as a logical .EXE or .DLL, and can be an application (with a main entry point) or a library. An assembly consists of one or more files (dlls, exes, html files etc), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.An important aspect of assemblies is that they are part of the identity of a type. The identity of a type is the assembly that houses it combined with the type name. This means, for example, that if assembly A exports a type called T, and assembly B exports a type called T, the .NET runtime sees these as two completely different types. Furthermore, don't get confused between assemblies and namespaces - namespaces are merely a hierarchical way of organising type names. To the runtime, type names are type names, regardless of whether namespaces are used to organise the names. It's the assembly plus the typename (regardless of whether the type name belongs to a namespace) that uniquely indentifies a type to the runtime.Assemblies are also important in .NET with respect to security - many of the security restrictions are enforced at the assembly boundary. Finally, assemblies are the unit of versioning in .NET - more on this below.14. What is the difference between a private assembly and a shared assembly?Location and visibility: A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes.Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.15. How do assemblies find each other?By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.16. How does assembly versioning work?Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of the referenced assembly.The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline - it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application configuration file.Remember: versioning is only applied to shared assemblies, not private assemblies.Application Domains17. What is an Application Domain?An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate an application from other applications.Win32 processes provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn't scale well. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory.18. How does an AppDomain get created?AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application.AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain, creates an instance of an object inside it, and then executes one of the object's methods. Note that you must name the executable 'appdomaintest.exe' for this code to work as-is.using System;using System.Runtime.Remoting;public class CAppDomainInfo : MarshalByRefObject{ public string GetAppDomainInfo(){ return "AppDomain = " + AppDomain.CurrentDomain.FriendlyName;} }public class App{ public static int Main(){ AppDomain ad = AppDomain.CreateDomain( "Andy's new domain", null, null );ObjectHandle oh = ad.CreateInstance( "appdomaintest", "CAppDomainInfo" );CAppDomainInfo adInfo = (CAppDomainInfo)(oh.Unwrap());string info = adInfo.GetAppDomainInfo();Console.WriteLine( "AppDomain info: " + info );return 0; } }1. What are the different modes for the sessionstates in the web.config file? Off Indicates that session state is not enabled.Inproc Indicates that session state is stored locally.StateServer Indicates that session state is stored on a remote server.SQLServer Indicates that session state is stored on the SQL Server.
2. What is smart navigation?When a page is requested by an Internet Explorer 5 browser, or later, smart navigation enhances the user's experience of the page by performing the following: • eliminating the flash caused by navigation. • persisting the scroll position when moving from page to page. • persisting element focus between navigations. • retaining only the last page state in the browser's history. Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual content that does not change dramatically on return. Consider this carefully when deciding whether to set this property to true.Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets this property. 3. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? 4. How would you get ASP.NET running in Apache web servers - why would you even do this? 5. What tags do you need to add within the asp:datagrid tags to bind columns manually 6. What base class do all Web Forms inherit from? System.Web.UI.Page 7. How can we create pie chart in asp.net? 8. Is it possible for me to change my aspx file extension to some other name?Yes.Open IIS->Default Website -> PropertiesSelect HomeDirectory tabClick on configuration buttonClick on add. Enter aspnet_isapi details (C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\aspnet_isapi.dll GET,HEAD,POST,DEBUG)
Open machine.config(C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\CONFIG) & add new extension under tag
9. What is AutoEventWireup attribute for ?
---WEBSERVICE & REMOTING---10. What is a WebService and what is the underlying protocol used in it?Why Web Services?Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.There are three main uses of Web services. 1. Application integration Web services within an intranet are commonly used to integrate business applications running on disparate platforms. For example, a .NET client running on Windows 2000 can easily invoke a Java Web service running on a mainframe or Unix machine to retrieve data from a legacy application. 2. Business integration Web services allow trading partners to engage in e-business leveraging the existing Internet infrastructure. Organizations can send electronic purchase orders to suppliers and receive electronic invoices. Doing e-business with Web services means a low barrier to entry because Web services can be added to existing applications running on any platform without changing legacy code. 3. Commercial Web services focus on selling content and business services to clients over the Internet similar to familiar Web pages. Unlike Web pages, commercial Web services target applications not humans as their direct users. Continental Airlines exposes flight schedules and status Web services for travel Web sites and agencies to use in their applications. Like Web pages, commercial Web services are valuable only if they expose a valuable service or content. It would be very difficult to get customers to pay you for using a Web service that creates business charts with the customers? data. Customers would rather buy a charting component (e.g. COM or .NET component) and install it on the same machine as their application. On the other hand, it makes sense to sell real-time weather information or stock quotes as a Web service. Technology can help you add value to your services and explore new markets, but ultimately customers pay for contents and/or business services, not for technology 11. Are Web Services a replacement for other distributed computing platforms?No. Web Services is just a new way of looking at existing implementation platforms. 12. In a Webservice, need to display 10 rows from a table. So DataReader or DataSet is best choice? Ans: WebService will support only DataSet. 13. How to generate WebService proxy? What is SOAP, WSDL, UDDI and the concept behind Web Services? What are various components of WSDL? What is the use of WSDL.exe utility?SOAP is an XML-based messaging framework specifically designed for exchanging formatted data across the Internet, for example using request and reply messages or sending entire documents. SOAP is simple, easy to use, and completely neutral with respect to operating system, programming language, or distributed computing platform.After SOAP became available as a mechanism for exchanging XML messages among enterprises (or among disparate applications within the same enterprise), a better way was needed to describe the messages and how they are exchanged. The Web Services Description Language (WSDL) is a particular form of an XML Schema, developed by Microsoft and IBM for the purpose of defining the XML message, operation, and protocol mapping of a web service accessed using SOAP or other XML protocol. WSDL defines web services in terms of "endpoints" that operate on XML messages. The WSDL syntax allows both the messages and the operations on the messages to be defined abstractly, so they can be mapped to multiple physical implementations. The current WSDL spec describes how to map messages and operations to SOAP 1.1, HTTP GET/POST, and MIME. WSDL creates web service definitions by mapping a group of endpoints into a logical sequence of operations on XML messages. The same XML message can be mapped to multiple operations (or services) and bound to one or more communications protocols (using "ports").The Universal Description, Discovery, and Integration (UDDI) framework defines a data model (in XML) and SOAP APIs for registration and searches on business information, including the web services a business exposes to the Internet. UDDI is an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, for the purpose of developing an Internet standard for web service description registration and discovery. Microsoft, IBM, and Ariba also are hosting the initial deployment of a UDDI service, which is conceptually patterned after DNS (the Internet service that translates URLs into TCP addresses). UDDI uses a private agreement profile of SOAP (i.e. UDDI doesn't use the SOAP serialization format because it's not well suited to passing complete XML documents (it's aimed at RPC style interactions). The main idea is that businesses use the SOAP APIs to register themselves with UDDI, and other businesses search UDDI when they want to discover a trading partner, for example someone from whom they wish to procure sheet metal, bolts, or transistors. The information in UDDI is categorized according to industry type and geographical location, allowing UDDI consumers to search through lists of potentially matching businesses to find the specific one they want to contact. Once a specific business is chosen, another call to UDDI is made to obtain the specific contact information for that business. The contact information includes a pointer to the target business's WSDL or other XML schema file describing the web service that the target business publishes. 14. How to generate proxy class other than .net app and wsdl tool?To access an XML Web service from a client application, you first add a Web reference, which is a reference to an XML Web service. When you create a Web reference, Visual Studio creates an XML Web service proxy class automatically and adds it to your project. This proxy class exposes the methods of the XML Web service and handles the marshalling of appropriate arguments back and forth between the XML Web service and your application. Visual Studio uses the Web Services Description Language (WSDL) to create the proxy.To generate an XML Web service proxy class: • From a command prompt, use Wsdl.exe to create a proxy class, specifying (at a minimum) the URL to an XML Web service or a service description, or the path to a saved service description.Wsdl /language:language /protocol:protocol /namespace:myNameSpace /out:filename/username:username /password:password /domain:domain 15. What is a proxy in web service? How do I use a proxy server when invoking a Web service? 16. asynchronous web service means? 17. What are the events fired when web service called? 18. How will do transaction in Web Services? 19. How does SOAP transport happen and what is the role of HTTP in it? How you can access a webservice using soap? 20. What are the different formatters can be used in both? Why?.. binary/soap Some example Questions :
1. Explain the differences between Server-side and Client-side code?Server side code basically gets executed on the server (for example on a webserver) per request/call basis, while client side code gets executed and rendered on the client side (for example web browser as a platform) per response basis.
2. What type of code (server or client) is found in a Code-Behind class?In the Code-behind class the server side code resides, and it generates the responses to the client appropriately while it gets called or requested.
3. What does the "EnableViewState" property do? Why would I want it on or off?EnableViewState stores the current state of the page and the objects in it like text boxes, buttons, tables etc. So this helps not losing the state between the round trips between client and server. But this is a very expensive on browser. It delays rendering on the browser, so you should enable it only for the important fields/objects.
4. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?Server.Transfer transfers the currnet context of the page to the next page and also avoids double roundtrips. Where as Response.Redirect could only pass querystring and also requires roundtrip.
5. How does VB.NET/C# achieve polymorphism?Polymorphism is achieved through virtual, overloaded, overridden methods in C# and VB.NET.
6. Whats an assemblyAn assembly is the primary building block of .NET. It's a reusable, self-describing,versionable deployment unit for types and resources. They are self-describing so to allowthe .NET runtime to fully understand the application and enforce dependency and versioning rules.
7. What is other name for shared assembly?Global Assembly
8. How do you create and use shared assemblies?using GACUtil.exe
9. How do you use thread in your .NET application?Derive your class from Thread Class
10. what are the main differences between Web Server controls and HTML Server controls?HTML Server controls are the nothing but some html tags with runat=server attribute in that tag. Web Server controls have richer event handling. HTML Server Controls need to be nested within a form tag. and so on.
11. Differences between ref and out parameters?out parameter need not be initialized, where as ref parameter needs to be. This clarifies that ref is both I/O parameter and out is only Output parameter as name suggests
12. When on the internet would you look for web services?I guess the question is where on the Internet would you look for web services. Go to UDDI Server and find.
13. Does .NET supports Pessimistic record locking or Optimistic record locking or both?both.
14. What is Catch API?I am not aware of any Catch API. If it is Cache then look for Cache class and if it is exception handling (try catch throw block) look for it.
15. which method do you use to redirect the user to another page without performing a round trip to the client?Server.Transfer
16. What base class do all web forms inherit from?System.web.UI.Page class. But for UserControl its System.Web.UI.UserControl
17. what method do you use to explicitly kill a users session?Session.Abandon
18. Which .NET class is used to validate an XML document?XMLValidatingReader.
19. What is AutoPostBackUse this property to specify whether the state of the control is posted back to the server when clicked, changes, list.
20. What is reflectionThe process of obtaining information about assemblies and the types defined within them, and creating, invoking, and accessing type instances at run time.0 comments Links to this post What are Lambda Expressions? With Lambda expressions you can treat code as data. In C# 1.0 / 2.0, it is common to pass strings, integers, reference types, and so on to methods so that the methods can act on those values.
Anonymous methods and lambda expressions extend the range of the values to include code blocks. This concept is common in functional programming.Explain the delegates in C#. Delegates in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.Here are some features of delegates: • A delegate represents a class. • A delegate is type-safe. • We can use delegates both for static and instance methods • We can combine multiple delegates into a single delegate. • Delegates are often used in event-based programming, such as publish/subscribe. • We can use delegates in asynchronous-style programming. • We can define delegates inside or outside of classes. Syntax of using delegates
//Declaring delegate delegate void SampleDelegate(string message);
// declare method with same signature:static void SampleDelegateMethod(string message) { Console.WriteLine(message); }
// create delegate object SampleDelegate d1 = SampleDelegateMethod;
// Invoke method with delegated1("my program"); Posted by Gurjinder Singh Brar 1 comments Labels: class, Delegates What is the purpose of connection pooling in ADO.NET? Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.
By default, the connection pool is created when the first connection with a unique connection string connects to the database. The pool is populated with connections up to the minimum pool size. Additional connections can be added until the pool reaches the maximum pool size.
When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released. But be sure than your connections use the same connection string each time. Here is the Syntax
conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB; Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";Posted by Gurjinder Singh Brar 0 comments Labels: Connection pooling, connection string What is the difference between classes and structs in Microsoft.Net? • A struct is a value type, while a class is a reference type. • When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack. • Classes can have explicit parameter less constructors. But structs cannot have this. • Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces. • We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type. • We can declare a destructor in class but can not in struct.Posted by Gurjinder Singh Brar 3 comments Labels: class, constructor, destructor, interface, memory, struct What is a Strong Name in Microsoft.Net? In Microsoft.Net a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key.Steps to create strong named assembly:
To create a strong named assembly you need to have a key pair (public key and a private key) file. Use sn -k KeyFile.snkOpen the dot net project to be complied as a strong named assembly. Open AssembyInfo.cs/ AssembyInfo.vb file. Add the following lines to AssemblyInfo file.[Assembly: AssemblyVersion("1.0.*")][assembly: AssemblyDelaySign(false)][assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]Compile the application, we have created a strong named assembly.Posted by Gurjinder Singh Brar 0 comments Labels: .net assembly, Microsoft.Net, private key, public key, strong named assembly What is the use of XSLT? XSLT stands for Extensible Stylesheet Language Transformations. This language used in XSL style sheets to transform XML documents into other XML documents.
XSLT is based on template rules which specify how XML documents should be processed. An XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it produce a new XML document. With XSLT we can also produce HTML or XHTML from XML document. With XSLT we can add/remove elements and attributes, rearrange and sort elements, hide and display elements from the output file. Converting XML to HTML for display is probably the most common application of XSLT today.Posted by Gurjinder Singh Brar 1 comments Labels: Extensible Stylesheet Language Transformations, XML, XML documents, XSL style sheets, XSLT Explain ACID properties of the database? All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and Durability• Atomicity: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed. • Consistency: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. • Isolation: It requires that multiple transactions occurring at the same time not impact each other’s execution. • Durability: It ensures that any transaction committed to the database will not be lost. Posted by Gurjinder Singh Brar 0 comments Labels: ACID properties, Atomicity, Consistency, Database, Durability, Isolation, transaction What is the basic functionality of Garbage Collector in Microsft.Net? The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.Here are the list of some tasks performed by the Garbage collector:• Garbage collector reserves a piece of memory as the application starts for the managed heap. • Garbage collector controls the managed heap memory currently used and available to an application. • Garbage collector allocates memory for new objects within the application. • The Garbage Collector attempts to reclaim the memory of objects that are not referenced. Posted by Gurjinder Singh Brar 0 comments Labels: Garbage collector, managed resources, memory management, Microsoft .NET Framework What is a static class? We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded.
Here are some more features of static class• Static classes only contain static members. • Static classes can not be instantiated. They cannot contain Instance Constructors • Static classes are sealed. Posted by Gurjinder Singh Brar 0 comments Labels: CLR, common language runtime, Static classes, static members What is static member of class? A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.To access a static class member, use the name of the class instead of an instance variableStatic methods and Static properties can only access static fields and static events.
Like: int i = Car.GetWheels;Here Car is class name and GetWheels is static property.
Static members are often used to represent data or calculations that do not change in response to object state.Posted by Gurjinder Singh Brar 0 comments Labels: static events, static members, static property What is the purpose of Server.MapPath method in Asp.Net? In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive. Syntax
Suppose your Text files are located at D:\project\MyProject\Files\TextFiles
If the root project directory is MyProject and the aspx file is located at root then to get the same path use code
//Physical path of TextFilesstring TextFilePath=Server.MapPath("Files/TextFiles");Posted by Gurjinder Singh Brar 0 comments Labels: physical path, Server.MapPath, virtual path What is the use of indexes and what are the types of indexes available in SQL Server? Indexes are used to find data quickly when a query is processed in any relational database. Indexes improve performance by 10 to 500 times. Index can improve the performance in following operations:• Find the records matching with WHERE clauseUPDATE Books SET Availability = 1 WHERE SubjectId =12 DELETE FROM Books WHERE Price <10SELECT * FROM Books WHERE Price BETWEEN 50 AND 80• Sorting the result with ORDER BYSELECT * FROM Books ORDER BY Price DESC• Grouping records and aggregate valuesSELECT Count(*) as Units, Price FROM Books GROUP BY PriceThere are two types of indexes available in SQL Server: clustered and non-clusteredClustered index Clustered index physically reorders the records of a table. Therefore a table can have only one clustered index. Usually a clustered index will be created on the primary key of a table. Non – Clustered IndexNon – Clustered index are stored in the order of the index key values, but the information in the table is stored in a different order. Means logical sorting of data not Physical. In SQl Server 2005 a table can have 249 non-clustered indexes.Composite IndexesA composite index is an index on two or more columns. Both clustered and non-clustered indexes can be composite indexes. If you have composite index on Price and BookName then take can take advantage of it like this:SELECT BookName, Price FROM Products ORDER BY UnitPrice BookName, Price DESC Posted by Gurjinder Singh Brar 0 comments Labels: Clustered index, Composite Indexes, Indexes, Non – Clustered index, relational database What is the difference between abstract class and interface? We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare abstract class.We can not make instance of Abstract Class as well as Interface. They only allow other classes to inherit from them. And abstract functions must be overridden by the implemented classes. Here are some differences in abstract class and interface.• An interface cannot provide code of any method or property, just the signature. we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. An abstract class can provide complete code of methods but there must exist a method or property without body.• A class can implement several interfaces but can inherit only one abstract class. Means multiple inheritance is possible in .Net through Interfaces. • If we add a new method to an Interface then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly. Posted by Gurjinder Singh Brar 0 comments Labels: Abstract Class, abstract functions, interface, multiple inheritance What is the use of Master Pages in Asp.Net? A master page in ASP.Net provides shared HTML, controls, and code that can be used as a template for all of the pages of a website.Every master page has asp:contentplaceholder control that will be filled by the content of the pages that use this master page. You can create a master page that has header and footer i.e. a logo, an image, left navigation bar etc and share this content on multiple pages. You need not to put these things on every aspx page. Posted by Gurjinder Singh Brar 0 comments Labels: ASP.NET, aspx page, master page What is the difference between .Net Remoting and Asp.Net Web Services? • ASP.NET Web Services Can be accessed only over HTTP but .Net Remoting Can be accessed over various protocols like TCP, HTTP, SMTP etc. • Web Services are based on stateless service architecture but .Net Remoting support for both stateful and stateless environment. • Web Services support heterogeneous environments means interoperability across platforms but .Net remoting requires .Net on both server and client end. • .NET Remoting provides the fast communication than Web Services when we use the TCP channel and the binary formatter. • Web services support only the objects that can be serialized but .NET Remoting can provide support to all objects that inherit MarshalByRefObject. • Web Services are reliable than .Net remoting because Web services are always hosted in IIS. • Web Services are ease to create and deploy but .Net remoting is bit complex to program. Posted by Gurjinder Singh Brar 0 comments Labels: .Net Remoting, ASP.NET, binary formatter, Web Services What would be the common layers in an n- tier architecture based web application? Common layers in an n- tier architecture • Presentation GUI: Look & Feel ,Html, aspx file, JavaScript, window forms etc. • Controller- Work flow layer: aspx.cs file, means event handlers and Data binding with controls etc. • Business Logic: where we implement business rules like add book, search library etc. • Data Access: SQLHelper.cs like create connection, get DataSet, Execute Query etc. • Physical Data: tables, views, stored procedures, indexes etc. Posted by Gurjinder Singh Brar 0 comments Labels: Common layers, n- tier architecture What are the different state management techniques used in asp.net for web applications? In ASP.Net the state can be maintained in following waysServer-side state managementApplication objectsSession VariablesDatabaseClient-side state managementCookiesHidden input fieldsQuery StringViewState

1 comments:

balotelli456 said...

Hi

I read this post two times.

I like it so much, please try to keep posting.

Let me introduce other material that may be good for our community.

Source: Security interview questions

Best regards
Henry