Sie sind auf Seite 1von 27

C# interview questions and answers

By admin | December 7, 2003 1. Whats the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time its being operated on, a new instance is created. 2. Can you store multiple data types in System.Array? No. 3. Whats the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow. 4. How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods. 5. Whats the .NET datatype that allows the retrieval of data by a unique key? HashTable. 6. Whats class SortedList underneath? A sorted HashTable. 7. Will finally block get executed if the exception had not occurred? Yes. 8. Whats the C# equivalent of C++ catch (), which was a catch-all statement for any possible exception? 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 {}. 9. Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block. 10. Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project. 11. Whats a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers. 12. Whats a multicast delegate? Its a delegate that points to and eventually fires off several methods. 13. Hows the DLL Hell problem solved in .NET? 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. 14. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command. 15. Whats a satellite assembly? 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. 16. What namespaces are necessary to create a localized application? System.Globalization, System.Resources. 17. Whats the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.

18. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch. 19. Whats the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example. 20. Is XML case-sensitive? Yes, so <Student> and <student> are different elements. 21. What debugging tools come with the .NET SDK? CorDBG command-line debugger, and DbgCLR graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. 22. What does the This window show in the debugger? It points to the object thats pointed to by this reference. Objects instance data is shown. 23. What does assert() do? 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. 24. Whats the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. 25. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities. 26. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. 27. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. 28. What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly). 29. Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window. 30. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources). 31. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? 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, but its a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines. 32. Whats the role of the DataReader class in ADO.NET connections? It returns a readonly dataset from the data source when the command is executed. 33. What is the wildcard character in SQL? Lets 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%. 34. Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no in-between case where something has been updated and something hasnt), Isolated (no transaction sees the intermediate results of

the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after). 35. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). 36. Which one is trusted and which one is untrusted? 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. 37. Why would you use untrusted verificaion? Web Services might use it, as well as nonWindows applications. 38. What does the parameter Initial Catalog define inside Connection String? The database name to connect to. 39. Whats the data provider name to connect to Access database? Microsoft.Access. 40. What does Dispose method do with the connection object? Deletes it from the memory. 41. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings

What is C# (C-Sharp)? C# is a new language created by Microsoft and submitted to the ECMA for standardization. According Microsoft "C# is a modern, object-oriented language that enables programmers to quickly build a wide range of applications for the new Microsoft .Net platform, which provides tools and services that fully exploit both computing and communications." What are the characteristics of C#? C# is designed for both computing and communication is characterized by several key features. It is 1. Simple 2. Consitent 3. Modern 4. Object-oriented

5. Type-safe 6. Versionable 7. Compatible 8. Interoprable and 9. Flexible What is BOXING and UNBOXING in C#? BOXING in C# is the conversion of a VALUE type on stack to a OBJECT type on the heap. Vice-versa the conversion from an OBJECT type back to a VALUE type is known as UNBOXING and it requires type casting. In how many ways you can create new copies of an existing string in C#? There are two ways: 1. Using overloaded = operator like - string s2 = s1; 2. Using the static Copy method like - string s2 = string.Copy(s1); In how many ways you can compare two strings in C# using overloaded methods and operators? There are three ways: 1. Overloaded Compare() method 2. Overloaded Equal() method 3. Overloaded == operator.

What is serialization? Serialization is the process of converting an object into a stream of bytes. De-serialization is the opposite process of creating an object from a stream of bytes. Serialization / De-serialization is mostly used to transport objects.

32. What are the difference between Structure and Class?


Structures are value type and Classes are reference type Structures can not have contractors or destructors. Classes can have both contractors and destructors. Structures do not support Inheritance, while Classes support Inheritance.

33. What is difference between Class And Interface? Class : is logical representation of object. It is collection of data and related sub procedures with defination. Interface : is also a class containg methods which is not having any definations.Class does not support multiple inheritance. But interface can support. 34. What is Delegates? Delegates are a type-safe, object-oriented implementation of function pointers and are used in many situations where a component needs to call back to the component that is using it. 35. What is Authentication and Authorization? Authentication is the process of identifying users. Authentication is identifying/validating the user against the credentials (username and password). Authorization performs after authentication. Authorization is the process of granting access to those users based on identity. Authorization allowing access of specific resource to user.

Can an Interface contain fields? No, an Interface cannot contain fields. Can you create an instance of an interface? No, you cannot create an instance of an interface. 1.Does C# support multiple-inheritance? No. But you can use Interfaces. 2.Where is a protected class-level variable available? It is available to any sub-class derived from base class

3.Are private class-level variables inherited? Yes, but they are not accessible. How do you create empty strings in C#? Using string.empty as shown in the example below. string EmptyString = string.empty; 4.Describe the accessibility modifier protected internal. It is available to classes that are within the same assembly and derived from the specified base class. 6.Which class is at the top of .NET class hierarchy? System.Object. 7.What does the term immutable mean? 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. 8.Whats the difference between System.String and System.Text.StringBuilder classes? System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. 9.Whats the advantage of using System.Text.StringBuilder over System.String? 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. 10.Can you store multiple data types in System.Array? No. 11.Whats the difference between the System.Array.CopyTo() and System.Array.Clone()? 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. 12.How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods. 13.Whats the .NET collection class that allows an element to be accessed using a unique key? HashTable. 14.What class is underneath the SortedList class? A sorted HashTable. 15.Will the finally block get executed if an exception has not occurred? Yes. 16.Whats the C# syntax to catch any possible exception? 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 {}.

17.Can multiple catch blocks be executed for a single try statement? No. Once the proper catch block processed, control is transferred to the finally block . 18.Explain the three services model commonly know as a three-tier application? Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources)

1. How many types of JIT compilers are available? There are Two types of JIT compilers. standard JIT compiler. EconoJIT compiler. 2.What are the different types of assemblies name them? Private Public/Shared Satellite assembly 3.What is GAC? What are the steps to be taken to pick up the latest version from GAC? This Global Assembly Cache(GAC) stores .NET assemblies to be shared by several applications on that computer.publisher policy file is the configuration file to redirect to different version 1. Create the publisher Policy assembly using the assembly linker 2. Add the publisher policy assembly to the GAC using GACutil tool Gacutil /i 3. During runtime CLR is looking into the publisher policy file and redirect the application to bind with new version assembly as specified inside the publisher policy.

4.How do we use different versions of private assemblies in same application without re-build? In Asseblyinfo file need specify assembly version. assembly: AssemblyVersion 5.Different methods of using a legacy COM component in .NET framework? 1. TLBIMP to create an Assembly from a COM component 2. Reference a COM component directly from .NET Editor 6.How do you implement SSL? 1. create certificate request [ =>Right click on the website (VD) =>Click Directory Security Tab and click Server Certificate => Type name of certificate , Organization name , server name location info, => Type the path need to save certificate information Submit certificate request. ] 7.What is ref parameter? What is out parameter? Ref Parameter: Used to pass a parameter as a reference so that the function called will set the value.

This could be used to return more than 1 value by a function. e.g. public int AddMuliply( int a , int b, ref int c) { c = a*b; return ( a+b); } The above function, returns the addition of two numbers as well as computes the multiplication result and passes to the calling function. Out Parameter: Used to pass values from the aspx Code-behind to the aspx page. The difference is that for a ref parameter, you have to assign a value before you call the function, while for OUT parameter, you dont have to assign a value, the calling function assumes that the called function would assign some value. A ref parameter must first be initialized before being passed from the calling function to the called function. but a out parameter need not be initialized, we can pass it directly when we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different, Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize. When to use out and ref parameter, out parameter is used when we want to return more than one value from a method. Ref parameter can be used as both input and o/p parameter out parameter can be used as only output parameter 8.What is boxing? What is the benefits and disadvantages? Boxing is converting a value-type to reference type. An example is converting an integer value to an object value. Ex: int intValue = 10; object obj = (object)intValue; This is used if you want to pass variables of object types to certain functions or methods you have created. Commonly used in events for example (Object sender...). 9.Why multiple Inheritance is not possible in C#? Multple inheritance is coneceptually wrong. It shouldn't be allowed in any language. Inheritance is the strongest relationship that can be expressed in OO languages. It's used to express IS-A relationship. Aggregation is used to express IS CONSTRUCTED IN TERMS OF. If you're using multiple inheritance in C++ then you're design is wrong and you probably want to use aggregation. On the other hand it's plausible to want to use multiple interfaces. For instance you might have a class wheel and a class engine. You could say that your class car inherits from wheel and from engine but that's wrong. In fact car aggregates wheel and engine because it is built in terms of those classes. If wheel is an interface and engine is an interface then car must inherit both of these interfaces since it must implement the functionaity of wheel and engine .On this basis we can see that multiple inheritance for classes should not be allowed because it promotes mis-use of the strong IS-A

relationship. C# enforces the correct concepts whilst C++ allows mis-use. multiple interface inheritance is permissible and C# allows this. It's all to do with properly understanding OO concepts. Absolute Multiple Inheritance is not possible in c# but partially it supports multiple inheritance by the use of Interfaces. As interfaces force a class to implement same type of behaviour (as defined in interface) which classes implements that interface

Which namespace enables multithreaded programming in XML? System.Threading 112. Can we declare a block as static in c#? No, because c# doesnot support static block, but it supports static method. 113. Can we declare a method as sealed? In C# a method can't be declared as sealed. However when we override a method in a derived class, we can declare the overridden method as sealed. By declaring it as sealed, we can avoid further overriding of this method. 114. What Command is used to implement properties in C#? get & set access modifiers are used to implement properties in c#. 115. What is static member? The member defined as static which can be invoked directly from the class level, rather than from its instance.

1) What is C#? C# is an object oriented, type safe and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.

2) What are the types of comment in C# with examples? Single line Eg:
//This is a Single line comment

ii. Multiple line (/* */) Eg:


/*This is a multiple line comment We are in line 2 Last line of comment*/

iii. XML Comments (///). Eg:


/// &lt;summary&gt; /// Set error message for multilingual language. /// &lt;/summary&gt;

3) Can multiple catch blocks be executed? No, Multiple catch blocks cant be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed.

4) What is the difference between public, static and void? All these are access modifiers in C#. Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created. And Void is a type modifier that states that the method or variable does not return any value.

5) What is an object? An object is an instance of a class through which we access the methods of that class. New keyword is used to create an object. A class that creates an object in memory will contain the information about the methods, variables and behavior of that class.

6) Define Constructors? A constructor is a member function in a class that has the same name as its class. The constructor is automatically invoked whenever an object class is created. It constructs the values of data members while initializing the class.

7) What is Jagged Arrays? The array which has elements of type array is called jagged array. The elements can be of different dimensions and sizes. We can also call jagged array as Array of arrays.

8) What is the difference between ref & out parameters? An argument passed as ref must be initialized before passing to the method whereas out parameter needs not to be initialized before passing to a method.

9) What is the use of using statement in C#? The using block is used to obtain a resource and use it and then automatically dispose of when the execution of block completed.

10) What is serialization? When we want to transport an object through network then we have to convert the object into a stream of bytes. The process of converting an object into a stream of bytes is called Serialization. For an object to be serializable, it should inherit ISerialize Interface. De-serialization is the reverse process of creating an object from a stream of bytes.

11) Can this be used within a static method? We cant use This in a static method because we can only use static variables/methods in a static method.

12) What is difference between constants and read-only? Constant variables are declared and initialized at compile time. The value cant be changed after wards. Read-only variables will be initialized only from the Static constructor of the class. Read only is used only when we want to assign the value at run time.

13) What is an interface class? Interface is an abstract class which has only public abstract methods and the methods only have the declaration and not the definition. These abstract methods must be implemented in the inherited classes.

14) What are value types and reference types? Value types are stored in the Stack whereas reference types stored on heap. Value types:
int, enum , byte, decimal, double, float, long

Reference Types:
string , class, interface, object.

15) What are Custom Control and User Control? Custom Controls are controls generated as compiled code (Dlls), those are easier to use and can be added to toolbox. Developers can drag and drop controls to their web forms. Attributes can be set at design time. We can easily add custom controls to Multiple Applications (If Shared Dlls), If they are private then we can copy to dll to bin directory of web application and then add reference and can use them. User Controls are very much similar to ASP include files, and are easy to create. User controls cant be placed in the toolbox and dragged dropped from it. They have their design and code behind. The file extension for user controls is ascx.

16) What are sealed classes in C#? We create sealed classes when we want to restrict the class to be inherited. Sealed modifier used to prevent derivation from a class. If we forcefully specify a sealed class as base class then a compile-time error occurs.

17) What is method overloading? Method overloading is creating multiple methods with the same name with unique signatures in the same class. When we compile, the compiler uses overload resolution to determine the specific method to be invoke.

18) What is the difference between Array and Arraylist? In an array, we can have items of the same type only. The size of the array is fixed. An arraylist is similar to an array but it doesnt have a fixed size.

19) Can a private virtual method be overridden? No, because they are not accessible outside the class.

20) Describe the accessibility modifier protected internal. Protected Internal variables/methods are accessible within the same assembly and also from the classes that are derived from this parent class.

21) What are the differences between System.String and System.Text.StringBuilder classes? System.String is immutable. When we modify the value of a string variable then a new memory is allocated to the new value and the previous memory allocation released. System.StringBuilder was designed to have concept of a mutable string where a variety of operations can be performed without allocation separate memory location for the modified string.

22) Whats the difference between the System.Array.CopyTo() and System.Array.Clone() ? Using Clone() method, we creates a new array object containing all the elements in the original array and using CopyTo() method, all the elements of existing array copies into another existing array. Both the methods perform a shallow copy.

23) How can we sort the elements of the array in descending order? Using Sort() methods followed by Reverse() method.

24) Write down the C# syntax to catch exception? To catch an exception, we use try catch blocks. Catch block can have parameter of system.Exception type. Eg:
try { GetAllData(); } catch(Exception ex) { }

In the above example, we can omit the parameter from catch statement.

25) Whats the difference between an interface and abstract class? Interfaces have all the methods having only declaration but no definition. In an abstract class, we can have some concrete methods. In an interface class, all the methods are public. An abstract class may have private methods.

26) What is the difference between Finalize() and Dispose() methods?

Dispose() is called when we want for an object to release any unmanaged resources with them. On the other hand Finalize() is used for the same purpose but it doesnt assure the garbage collection of an object.

27) What are circular references? Circular reference is situation in which two or more resources are interdependent on each other causes the lock condition and make the resources unusable.

28) What are generics in C#.NET? Generics are used to make reusable code classes to decrease the code redundancy, increase type safety and performance. Using generics, we can create collection classes. To create generic collection, System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace. Generics promotes the usage of parameterized types.

29) What is an object pool in .NET? An object pool is a container having objects ready to be used. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and re-creating objects.

30) List down the commonly used types of exceptions in .Net? ArgumentException, ArgumentNullException , ArgumentOutOfRangeException, ArithmeticException, DivideByZeroException ,OverflowException , IndexOutOfRangeException ,InvalidCastException ,InvalidOperationException , IOEndOfStreamException , NullReferenceException , OutOfMemoryException , StackOverflowException etc.

31) What are Custom Exceptions? Sometimes there are some errors that need to be handeled as per user requirements. Custom exceptions are used for them and are used defined exceptions.

32) What are delegates? Delegates are same are function pointers in C++ but the only difference is that they are type safe unlike function pointers. Delegates are required because they can be used to write much more generic type safe functions.

33) How do you inherit a class into other class in C#? Colon is used as inheritance operator in C#. Just place a colon and then the class name.
public class DerivedClass : BaseClass

34) What is the base class in .net from which all the classes are derived from?
System.Object

35) What is the difference between method overriding and method overloading? In method overriding, we change the method definition in the derived class that changes the method behavior. Method overloading is creating a method with the same name within the same class having different signatures.

36) What are the different ways a method can be overloaded? Methods can be overloaded using different data types for parameter, different order of parameters, and different number of parameters.

37) Why cant you specify the accessibility modifier for methods inside the interface? In an interface, we have virtual methods that do not have method definition. All the methods are there to be overridden in the derived class. Thats why they all are public.

38) How can we set class to be inherited, but prevent the method from being over-ridden? Declare the class as public and make the method sealed to prevent it from being overridden.

39) What happens if the inherited interfaces have conflicting method names? Implement is up to you as the method is inside your own class. There might be problem when the methods from different interfaces expect different data, but as far as compiler cares youre okay.

40) What is the difference between a Struct and a Class? Structs are value-type variables and classes are reference types. Structs stored on the stack, causes additional overhead but faster retrieval. Structs cannot be inherited.

41) How to use nullable types in .Net? Value types can take either their normal values or a null value. Such types are called nullable types.
Int? someID = null; If(someID.HasVAlue) { }

42) How we can create an array with non-default values? We can create an array with non-default values using Enumerable.Repeat.

43) What is difference between is and as operators in c#? is operator is used to check the compatibility of an object with a given type and it returns the result as Boolean. as operator is used for casting of object to a type or a class.

44) Whats a multicast delegate? A delegate having multiple handlers assigned to it is called multicast delegate. Each handler is assigned to a method.

45) What are indexers in C# .NET? Indexers are known as smart arrays in C#. It allows the instances of a class to be indexed in the same way as array. Eg:
public int this[int index] // Indexer declaration

46) What is difference between the throw and throw ex in .NET? Throw statement preserves original error stack whereas throw ex have the stack trace from their throw point. It is always advised to use throw because it provides more accurate error information.

47) What are C# attributes and its significance? C# provides developers a way to define declarative tags on certain entities eg. Class, method etc. are called attributes. The attributes information can be retrieved at runtime using Reflection.

48) How to implement singleton design pattern in C#? In singleton pattern, a class can only have one instance and provides access point to it globally. Eg:
Public sealed class Singleton { Private static readonly Singleton _instance = new Singleton(); }

49) What is the difference between directcast and ctype? DirectCast is used to convert the type of an object that requires the run-time type to be the same as the specified type in DirectCast. Ctype is used for conversion where the conversion is defined between the expression and the type.

50) Is C# code is managed or unmanaged code?

C# is managed code because Common language runtime can compile C# code to Intermediate language. - See more at: http://www.fresherventure.net/frequently-asked-c-language-interview-questionsand-answers-2/#sthash.pZpNifr6.dpuf

How does C# differ from C++?


C# does not support #include statement. It uses only using statement. In C# , class definition does not use a semicolon at the end. C# does not support multiple code inheritance. Casting in C# is much safer than in c++. In C# switch can also be used on string values. Command line parameters array behave differently in C# as compared to C++.

92. What is nested class?


A Nested classes are classes within classes. A nested class is any class whose declaration occurs within the body of another class or interface.

93. Can you have parameters for static constructors? No, static constructors cannot have parameters. 94. Is String is Value Type or Reference Type in C#? String is an object(Reference Type). 95. Does C# provide copy constructor?

No, C# does not provide copy constructor.

What is the difference between Array and LinkedList? Array is a simple sequence of numbers which are not concerned about each others positions. they are independent of each others positions. adding,removing or modifying any array element is very easy. Compared to arrays ,linked list is a comlicated sequence of numbers. 72. Does C# have a throws clause? No, unlike Java, C# does not require the developer to specify the exceptions that a method can throw. 73. Does C# support a variable number of arguments? Yes, uisng the params keyword. The arguments are specified as a list of arguments of a specific type. 74. Can you override private virtual methods? No, private methods are not accessible outside the class. 75. What is a multi cast delegates? Each delegate object holds reference to a single method. However, it is possible for a delegate object to hold references of and invoke multiple methods. Such delegate objects are called multicast delegates or combinable delegates.

.net q

What is an application server?


As defined in Wikipedia, an application server is a software engine that delivers applications to client computers or devices. The application server runs your server code. Some well known application servers are IIS (Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).

Compare C# and VB.NET


A detailed comparison can be found over here.

What is a base class and derived class?


A class is a template for creating an object. The class from which other classes derive fundamental functionality is called a base class. For e.g. If Class Y derives from Class X, then Class X is a base class. The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.

What is an extender class?

An extender class allows you to extend the functionality of an existing control. It is used in Windows forms applications to add properties to controls. A demonstration of extender classes can be found over here.

What is inheritance?
Inheritance represents the relationship between two classes where one type derives functionality from a second type and then extends it by adding new methods, properties, events, fields and constants. C# support two types of inheritance: Implementation inheritance Interface inheritance

What is implementation and interface inheritance?


When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance. When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance. In general Classes can be derived from another class, hence support Implementation inheritance. At the same time Classes can also be derived from one or more interfaces. Hence they support Interface inheritance. Source: Exforsys.

What is inheritance hierarchy?


The class which derives functionality from a base class is called a derived class. A derived class can also act as a base class for another class. Thus it is possible to create a tree-like structure that illustrates the relationship between all related classes. This structure is known as the inheritance hierarchy.

How do you prevent a class from being inherited?


In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.

When should you use inheritance?


Read this.

Define Overriding?
Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.

Can you use multiple inheritance in .NET?

.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.

Why dont we have multiple inheritance in .NET?


There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.

What is an Interface?
An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.

When should you use abstract class vs interface or What is the difference between an abstract class and interface?
I would suggest you to read this. There is a good comparison given over here.

What are events and delegates?


An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.

What is business logic?

It is the functionality which handles the exchange of information between database and a user interface.

What is a component?
Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.

What is a control?

A control is a component that provides user-interface (UI) capabilities. The differences can be studied over here.

What are the differences between a control and a component?

What are design patterns?


Design patterns are common solutions to common design problems.

What is a connection pool?

A connection pool is a collection of connections which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused.

What is a flat file?

A flat file is the name given to text, which can be read or written only sequentially.

What are functional and non-functional requirements?

Functional requirements defines the behavior of a system whereas non-functional requirements specify how the system should behave; in other words they specify the quality requirements and judge the behavior of a system. E.g. Functional - Display a chart which shows the maximum number of products sold in a region. Non-functional The data presented in the chart must be updated every 5 minutes.

What is the global assembly cache (GAC)?


GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dlls (DLL Hell).

What is a stack? What is a heap? Give the differences between the two?

Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored. Check this link for the differences.

What is instrumentation? What is code review? What is logging?

It is the ability to monitor an application so that information about the applications progress, performance and status can be captured and reported. The process of examining the source code generally through a peer, to verify it against best practices. Logging is the process of persisting information about the status of an application.

What are mock-ups?

Mock-ups are a set of designs in the form of screens, diagrams, snapshots etc., that helps verify the design and acquire feedback about the applications requirements and use cases, at an early stage of the design process.

What is a Form?

A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.

What is a multiple-document interface(MDI)? What is a single-document interface (SDI) ? What is BLOB ?

A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel. A user interface that is created to manage graphical user interfaces and controls into single windows. E.g. Microsoft Word

A BLOB (binary large object) is a large item such as an image or an exe represented in binary form.

What is ClickOnce?
ClickOnce is a new deployment technology that allows you to create and publish selfupdating applications that can be installed and run with minimal user interaction.

What is object role modeling (ORM) ? What is a private assembly? What is a shared assembly?

It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon etc. A private assembly is local to the installation directory of an application and is used only by that application. A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.

What is the difference between user and custom controls?

User controls are easier to create whereas custom controls require extra effort. User controls are used when the layout is static whereas custom controls are used in dynamic layouts. A user control cannot be added to the toolbox whereas a custom control can be. A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.

Where do custom controls reside?


In the global assembly cache (GAC).

What is a third-party control ?


A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (thirdparty).

What is a binary formatter? What is Boxing/Unboxing?

Binary formatter is used to serialize and deserialize an object in binary format.

Boxing is used to convert value types to object. E.g. int x = 1; object obj = x ; Unboxing is used to convert the object back to the value type. E.g. int y = (int)obj; Boxing/unboxing is quiet an expensive operation.

What is a COM Callable Wrapper (CCW)?


CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.

What is a Runtime Callable Wrapper (RCW)?


RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.

What is a digital signature?


A digital signature is an electronic signature used to verify/gurantee the identity of the individual who is sending the message.

What is garbage collection?


Garbage collection is the process of managing the allocation and release of memory in your applications. Read this article for more information.

What is globalization?
Globalization is the process of customizing applications that support multiple cultures and regions.

What is localization?
Localization is the process of customizing applications that support a given culture and regions.

What is MIME?
The definition of MIME or Multipurpose Internet Mail Extensions as stated in MSDN is MIME is a standard that can be used to include content of various types in a single message. MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages to include multiple content, both textual and non-textual. Parts of the message may be images, audio, or text in different character sets. The MIME standard derives from RFCs such as 2821 and 2822. Quoted from here.

.Net Interview Questions and Answers


What is .NET? .NET is essentially a framework for software development. It is similar in nature to any other software development framework (J2EE etc) in that it provides a set of runtime containers/capabilities, and a rich set of pre-built functionality in the form of class libraries and APIs The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET.

How many languages .NET is supporting now? When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported. How is .NET able to support multiple languages? A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language. How ASP .NET different from ASP? Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server. What is smart navigation? The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed. What is view state? The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control How do you validate the controls in an ASP .NET page? Using special validation controls that are meant for this. We have Range Validator, Email Validator. Can the validation be done in the server side? Or this can be done only in the Client side? Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done. How to manage pagination in a page? Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself. What is ADO .NET and what is difference between ADO and ADO.NET? ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

Das könnte Ihnen auch gefallen