120 likes | 159 Views
Whether you're a candidate or interviewer, these interview questions will help ... He is particularly interested in client/server and mobile applications using ASP.NET ... NET and C# developer with over fifteen years of experience in creating web.
E N D
Asp.Net C# Interview Questions and Answers By Hope Tutors www.hopetutors.com
Explain namespaces in C#? Ans. The built-in libraries are organized within namespaces. Namespaces organize objects in an assembly. An assembly is a reusable, version able and self-describing building block of a CLR application. Assemblies can contain multiple namespaces. Namespaces can contain other namespaces. We can add namespaces in our application used the “using” keyword. Example- using System; using System.Collections.Generic; www.hopetutors.com
Explain namespaces in C#? Ans. The built-in libraries are organized within namespaces. Namespaces organize objects in an assembly. An assembly is a reusable, version able and self-describing building block of a CLR application. Assemblies can contain multiple namespaces. Namespaces can contain other namespaces. We can add namespaces in our application used the “using” keyword. Example- using System; using System.Collections.Generic; www.hopetutors.com
What is concept of Boxing and Unboxing ? Ans. 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. www.hopetutors.com
Is it possible to use multiple inheritance in .NET? Ans. Multiple Inheritance is an ability to inherit from more than one base class i.e. ability of a class to have more than one super class, by inheriting from different sources and thus combine separately-defined behaviors in a single class. There are two types of multiple inheritance: * multiple type/interface inheritance * multiple implementation inheritance C# supports only multiple type/interface inheritance. There is no support for multiple implementation inheritance in .NET. That means a class can only derived from one class. www.hopetutors.com
What is a delegates in c#? Ans. A delegate is a type safe function pointer. Using delegates you can pass methods as parameters. To pass a method as a parameter, to a delegate, the signature of the method must match the signature of the delegate. This is why, delegates are called type safe function pointers. Delegate declaration determines the methods that can be referenced by the delegate. A delegate can refer to a method, which has the same signature as that of the delegate.For example, consider a delegate: public delegate int MyDelegate (string s); The preceding delegate can be used to reference any method that has a single string parameter and returns an int type variable. Syntax for delegate declaration is: delegate <return type> <delegate-name> <parameter list> www.hopetutors.com
What type of class cannot be inherited? Define Constructors in C#? Ans. A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note that a struct is implicitly sealed; so they cannot be inherited. Ans. 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. www.hopetutors.com
What is an object in c-sharp? What is the use and purpose of using keyword? Ans. 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. Ans. The using keyword is used to define block of code with the guarantee that anything present within the body of using will be dispose off (even if the exception has been thrown).The use of this keyword is excellent as it cleans the garbage in the memory automatically by disposing which implements IDisposable interface. www.hopetutors.com
What is Event? Ans. Notification by an application or operating system that some event has occurred. An event is fired—raised—when a predefined condition occurs, e.g., focus change in a GUI, interval timer, mouse click. An event handler is called in response to an event. The C# event model is publish and subscribe: Publishers create and publish events: Subscribers register to receive specific events: Then, publishers send out their events only to subscribers. www.hopetutors.com
Is C# fully object oriented language? Ans. Yes, you can say C# is a fully object oriented language. It not only supports the four criteria of OOPs, it also requires that essentially all of your constructs be encapsulated in objects. That is, C# does not let you develop outside of the OOPs methodology in any meaningful way. www.hopetutors.com
Class Vs Structure in c#? Ans. Following are the key differences between them: - 1. Structures are value types and classes are reference types. So structures use stack and classes use heap. 2. Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures. 3. Structures do not require constructors while classes require. 4. Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC. www.hopetutors.com