Technicalsymposium.com - New Updates Alerts-Subscribe


Our Telegram Channel - Join Us


Our Free Email Alerts - Join Us



Important Note:Login & Check Your
Email Inbox and Activate Confirmation Link

Our Whatsapp Group - Join Us


Technical Interview Materials PDF-Free Download





Technical Interview Q & A PDF





1. What is C#? 

C# is the best language for writing Microsoft .NET applications. C# provides the rapid application development found in Visual Basic with the power of C++. Its syntax is similar to C++ syntax and meets 100% of the requirements of OOPs like the following:

• Abstraction

• Encapsulation

• Polymorphism

• Inheritance

2. What is an Object?

According to MSDN, "a class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically". 

Objects helps us to access the member of a class or struct either they can be fields, methods or 

3. What is Managed or Unmanaged Code?

Managed Code 

“The code, which is developed in .NET framework is known as managed code. This code is directly executed by CLR with the help of managed code execution. Any language that is written in .NET Framework is managed code”. 

Unmanaged Code 

The code, which is developed outside .NET framework is known as unmanaged code. 

“Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with the code of VB, ASP and COM are examples of unmanaged code”. 

Unmanaged code can be unmanaged source code and unmanaged compile code. Unmanaged code is executed with the help of wrapper classes. 

Wrapper classes are of two types:

• CCW (COM Callable Wrapper).

• RCW (Runtime Callable Wrapper).

4. What is Boxing and Unboxing?

Answer: Boxing and Unboxing both are used for type conversion but have some difference: 

Boxing: 

Boxing is the process of converting a value type data type to the object or to any interface data type which is implemented by this value type. When the CLR boxes a value means when CLR is converting a value type to Object Type, it wraps the value inside a System.Object and stores it on the heap area in application domain. 

Example: 

Unboxing: 

Unboxing is also a process which is used to extract the value type from the object or any implemented interface type. Boxing may be done implicitly, but unboxing have to be explicit by code. 

Example: 

The concept of boxing and unboxing underlines the C# unified view of the type system in which a value of any type can be treated as an object. 

5. What is the difference between a struct and a class in C#? 

Answer:

Class and struct both are the user defined data type but have some major difference: 

Struct

• The struct is value type in C# and it inherits from System.Value Type.

• Struct is usually used for smaller amounts of data.

• Struct can’t be inherited to other type.

• A structure can't be abstract.

• No need to create object by new keyword.

• Do not have permission to create any default constructor.

Class

• The class is reference type in C# and it inherits from the System.Object Type.

• Classes are usually used for large amounts of data.

• Classes can be inherited to other class.

• A class can be abstract type.

• We can’t use an object of a class with using new keyword.

• We can create a default constructor.

• 6. What is the difference between Interface and Abstract Class? 

Answer: 

Theoretically their are some differences between Abstract Class and Interface which are listed below:

• A class can implement any number of interfaces but a subclass can at most use only one abstract class. 

• An abstract class can have non-abstract methods (concrete methods) while in case of interface all the methods has to be abstract. 

• An abstract class can declare or use any variables while an interface is not allowed to do so. 

• In an abstract class all data member or functions are private by default while in interface all are public, we can’t change them manually. 

• In an abstract class we need to use abstract keyword to declare abstract methods while in an interface we don’t need to use that. 

• An abstract class can’t be used for multiple inheritance while interface can be used as multiple inheritance. 

• An abstract class use constructor while in an interface we don’t have any type of constructor. 

7. What is enum in C#? 

Answer: 

An enum is a value type with a set of related named constants often referred to as an enumerator list. The enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined. 

An enum type can be an integer (float, int, byte, double etc.). But if you used beside int it has to be cast. 

An enum is used to create numeric constants in .NET framework. All the members of enum are of enum type. Their must be a numeric value for each enum type. 

The default underlying type of the enumeration element is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1. 

1. enum Dow {Sat, Sun, Mon, Tue, Wed, Thu, Fri}; 

Some points about enum 

• Enums are enumerated data type in c#.

• Enums are not for end-user, they are meant for developers.

• Enums are strongly typed constant. They are strongly typed, i.e. an enum of one type may not be implicitly assigned to an enum of another type even though the underlying value of their members are the same. 

• Enumerations (enums) make your code much more readable and understandable.

• Enum values are fixed. Enum can be displayed as a string and processed as an integer.

• The default type is int, and the approved types are byte, sbyte, short, ushort, uint, long, and ulong.

• Every enum type automatically derives from System.Enum and thus we can use System.Enum methods on enums.

• Enums are value types and are created on the stack and not on the heap.

Source: Contents are provided by Technicalsymposium Google Group Members. 
Disclaimer: All the above contents are provided by technicalsymposium.com Google Group members. 
Further, this content is not intended to be used for commercial purpose. Technicalsymposium.com is not liable/responsible for any copyright issues.


Technicalsymposium.com-All Quick Links & Study Notes PDF- Free Download