Top 50 C# Interview Questions and Answers for freshers and experienced. TOP MOST C# INTERVIEW QUESTIONS and ANSWERSC#. NET INTERVIEW QUESTIONS and ANSWERS : -. What is C#? C# (pronounced . It will immediately be familiar to C and C++ programmers. C# combines the high productivity of Rapid Application Development (RAD) languages. What are the types of comment in C#? There are 3 types of comments in C#. Single line (//)Multi (/* */)Page/XML Comments (///). This is the c# programming questions and answers section on '.NET. C#.NET/VB.NET interview questions Explain the elements of the.NET Framework. The.Net runtime knows about all the references between the objects. Http:// Visit Us At http://career.guru99.com/top-50-c-sharp-interview-questions-answers/. C# Interview Questions and Answers. Contains Important C Sharp.Net Interview Questions with Answers and C Sharp.Net FAQs. What are the namespaces used in C#.NET? C# Interview Questions, Answers, and Explanations: C Sharp Certification Review.NET Interview Questions and Answers. Home / Latest Articles / Microsoft / Top 50 C# Interview Questions and Answers. Questions & Answers.NET Technology Interview. C-Sharp-Interview-Questions. What are the namespaces used in C#. NET? Namespace is a logical grouping of class. System; using System. Collections. Generic; using System. Windows. Forms; 4. What are the characteristics of C#? There are several characteristics of C# are : Simple. Type safe. Flexible. Object oriented. Compatible. Consistent. Interoperable. Modern. 5. What are the different categories of inheritance? Inheritance in Object Oriented Programming is of four types: Single inheritance: Contains one base class and one derived class. Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class. Multilevel inheritance: Contains a class derived from a derived class. Multiple inheritance: Contains several base classes and a derived class. What are the basic concepts of object oriented programming? It is necessary to understand some of the concepts used extensively in object oriented programming. These include: Objects. Classes. Data abstraction and encapsulation. Inheritance. Polymorphism. Dynamic Binding. Message passing. Can you inherit multiple interfaces? Yes. Multiple interfaces may be inherited in C#. What is inheritance? Inheritance is deriving the new class from the already existing one. Define scope? Scope refers to the region of code in which a variable may be accessed. What is the difference between public, static and void? The keyword public is an access modifier that tells the C# compiler that the Main method is accessible by anyone. The keyword static declares that the Main method is a global one and can be called 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. The keyword void is a type modifier that states that the Main method does not return any value. What are the modifiers in C#? Abstract. Sealed. Virtual. Const. Event. Extern. Override. Readonly. Static. New. 12. What are the types of access modifiers in C#? Access modifiers in C# are : publicprotectprivateinternalinternal protect. What is boxing and unboxing? Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion. Conversion of reference type variable back to value type is called as Un. Boxing. 1. 4. What is object? An object is an instance of a class. An object is created by using operator new. A class that creates an object in memory will contain the information about the values and behaviors (or methods) of that specific object. Where are the types of arrays in C#? Single- Dimensional. Multidimensional. Jagged arrays. 1. What is the difference between Object and Instance? An instance of a user- defined type is called an object. We can instantiate many objects from one class. An object is an instance of a class. Define destructors? A destructor is called for a class object when that object passes out of scope or is explicitly deleted. A destructors as the name implies is used to destroy the objects that have been created by a constructors. Like a constructor , the destructor is a member function whose name is the same as the class name but is precised by a tilde. What is the use of enumerated data type? An enumerated data type is another user defined type which provides a way for attaching names to numbers thereby increasing comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2, and so on. Define Constructors? A constructor is a member function with the same name as its class. The constructor is invoked whenever an object of its associated class is created. It is called constructor because it constructs the values of data members of the class. What is encapsulation? The wrapping up of data and functions into a single unit (called class) is known as encapsulation. Encapsulation containing and hiding information about an object, such as internal data structures and code. Does c# support multiple inheritance? No,its impossible which accepts multi level inheritance. What is ENUM? Enum are used to define constants. What is a data set? A Data. Set is an in memory representation of data loaded from any data source. What is the difference between private and public keyword? Private: The private keyword is the default access level and most restrictive among all other access levels. It gives least permission to a type or type member. A private member is accessible only within the body of the class in which it is declared. Public: The public keyword is most liberal among all access levels, with no restrictions to access what so ever. A public member is accessible not only from within, but also from outside, and gives free access to any member declared within the body or outside the body. Define polymorphism? Polymorphism means one name, multiple forms. It allows us to have more than one function with the same name in a program. It allows us to have overloading of operators so that an operation can exhibit different behaviors in different instances. What is Jagged Arrays? A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an array–of–arrays. What is an abstract base class? An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function. How is method overriding different from method overloading? When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class. What is the difference between ref & out parameters? An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter. What is the use of using statement in C#? The using statement is used to obtain a resource, execute a statement, and then dispose of that resource. 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. 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. 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. 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. 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. What is a base class? A class declaration may specify a base class by following the class name with a colon and the name of the base class. Can “this” be used within a static method? No . As only static variables/methods can be used in a static method. What is difference between constants, readonly and, static ? Constants: The value can’t be changed. Read- only: The value will be initialized only once from the constructor of the class. Static: Value can be initialized once. What are the different types of statements supported in C#? C# supports several different kinds of statements are. Block statements. Declaration statements. Expression statements. Selection statements. Iteration statements. Jump statements. Try catch statements. Checked and unchecked. Lock statement. 40. What is an interface class? It is an abstract class with public abstract methods all of which must be implemented in the inherited classes. What are value types and reference types? Value types are stored in the Stack. Examples : bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort. Reference types are stored in the Heap. Examples : class, delegate, interface, object, string. What is the difference between string keyword and System. String class? String keyword is an alias for Syste. String class. Therefore, System. String and string keyword are the same, and you can use whichever naming convention you prefer. The String class provides many methods for safely creating, manipulating, and comparing strings. What are the two data types available in C#? Value type. Reference type. What are the different types of Caching? There are three types of Caching: Output Caching: stores the responses from an asp. Fragment Caching: Only caches/stores the portion of page (User Control)Data Caching: is Programmatic way to Cache objects for performance. What is the difference between Custom Control and User Control? Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. C# developer interview questions and answers. Good help is hard to find. There is an art to finding a developer who fits well in your organization in terms of personality and work ethic; fortunately, it's more straightforward to determine their technical expertise. I worked at a couple of places where development managers loved drilling job candidates on syntax while having them write code, and it was clearly a stressful experience for the interviewee. I do not like asking specific syntax questions during interviews since most developers do not know language syntax or class names off the top of their heads. In terms of the basic interview, I prefer to ask open- ended questions where the candidate can explain concepts and how they would attack problems. Some organizations like to give candidates tests or have them eyeball code snippets to spot problems, and I think those are good evaluation tools. This is the first installment in our series of programming language- specific development interview questions and answers. Here is a list of questions (and the answers to those questions) that will help you get a feel for a candidate's proficiency with C#. You can ask follow- up questions based on their replies. Note: This content is also available as a downloadable PDF. What are namespaces, and how they are used? Namespaces are used to organize classes within the . NET Framework. They dictate the logical structure of the code. They are analogous to Java packages, with the key difference being Java packages define the physical layout of source files (directory structure) while . NET namespaces do not. However, many developers follow this approach and organize their C# source files in directories that correlate with namespaces. The . NET Framework has namespaces defined for its many classes, such as System. Xml—these are utilized via the using statement. Namespaces are assigned to classes via the namespace keyword. What is a constructor? A constructor is a class member executed when an instance of the class is created. The constructor has the same name as the class, and it can be overloaded via different signatures. Constructors are used for initialization chores. What is the GAC, and where is it located? The GAC is the Global Assembly Cache. Shared assemblies reside in the GAC; this allows applications to share assemblies instead of having the assembly distributed with each application. Versioning allows multiple assembly versions to exist in the GAC—applications can specify version numbers in the config file. The gacutil command line tool is used to manage the GAC. Why are strings in C# immutable? Immutable means string values cannot be changed once they have been created. Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and extraneous garbage collection. The mutable System. Text. String. Builder class should be used when string values will change. When a DLL (or assembly) is loaded in . NET, it is loaded by name, version, and certificate. The assembly contains all of this information via its metadata. The GAC provides the solution, as you can have multiple versions of a DLL side- by- side. How are methods overloaded? Methods are overloaded via different signatures (number of parameters and types). Thus, you can overload a method by having different data types, different number of parameters, or a different order of parameters. How do you prevent a class from being inherited? The sealed keyword prohibits a class from being inherited. What is the execution entry point for a C# console application? The Main method. How do you initiate a string without escaping each backslash? You put an @ sign in front of the double- quoted string. String ex = @. Structs are passed by value and not by reference. Structs are stored on the stack not the heap. The result is better performance with Structs. What is a singleton? A singleton is a design pattern used when only one instance of an object is created and shared; that is, it only allows one instance of itself to be created. Any attempt to create another instance simply returns a reference to the first one. Singleton classes are created by defining all class constructors as private. In addition, a private static member is created as the same type of the class, along with a public static member that returns an instance of the class. Here is a basic example: public class Singleton. Example . Basically, this involves creating a new object on the heap and placing the value there. Reversing the process is just as easy with unboxing, which converts the value in an object reference on the heap into a corresponding value type on the stack. The unboxing process begins by verifying that the recipient value type is equivalent to the boxed type. If the operation is permitted, the value is copied to the stack. Keep your engineering skills up to date by signing up for Tech. Republic's free Software Engineer newsletter, delivered each Tuesday.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |