1. Question:What is the CLR? 

    Answer
    The .NET Framework provides a run-time environment called the common language run-time, which runs the code and provides services that make the development process easier.

    1. Report
  2. Question:What are value and reference types? 

    Answer
    Value type: The content of a value type variable or constant is simply a value. For example, the content of the built-in value type, int, is 32 bits of data. Its contents in memory is allocated on the stack. We can define a custom value type with the 'struct' keyword.
    public struct Point { public int X, Y; }
    Reference type: A reference type has two parts: an object and the reference to that object. The content of a reference-type variable or constant is a reference to an object that contains the value. A reference type, such as an instance of a class or an array, is allocated in a different area of memory called the heap. We use 'class' keyword to define it.
    public class Point { public int X, Y; }

    1. Report
  3. Question:Define Method Overloading? ` 

    Answer
    Method overload defines use different type of parameters with  same method name or different set of parameters is known as Method Overloading.
    void Foo (int x);
    void Foo (double x);
    void Foo (int x, float y);

    1. Report
  4. Question:Define Stack and Heap in term of memory. 

    Answer
    Stack: The stack is a block of memory for storing local variables and parameters.The stack is always reserved in a LIFO (last in first out) order;
    The stack is important to consider in exception handling and thread executions.Heap: The heap is memory set aside for dynamic allocation. You can allocate a block at any time and free it at any time.

    1. Report
  5. Question:Define ref, out and params modifier? 

    Answer
    In C# ref modifier is used to pass arguments by reference.
    Out: An out modifier is like a ref modifier except it need not be assigned before going into the function.
    Params: The params modifier may be specified on the last parameter of a method so that the method accepts any number of parameters of a particular type. The parameter type must be declared as an array.

    1. Report
  6. Question:What is finalizer? 

    Answer
    Finalizers are class-only methods that execute before the garbage collector reclaims the memory for an unreferenced object. 
    This is  actually C# syntax for overriding  Object’s  Finalize method. The syntax for a finalizer is the name of the class prefixed with the ~ symbol:
    class Class1
    {
    ~Class1(){...}
    }

    1. Report
  7. Question:Define Abstract classes and Abstract members. 

    Answer
    Abstract Class: An abstract class is to provide a common definition of a base class that multiple derived classes can share. It cannot be instantiated.Abstract Member : Abstract classes are able to define abstract members. Abstract members are like virtual  members,  except  they  don’t  provide  a  default  implementation

    1. Report
  8. Question:Define Enums? 

    Answer
    An enum (also named an enumeration)  is  a special value type that lets you specify a group of named numeric constants. 
    Example:
    public enum BorderSide { Left, Right, Top, Bottom }

    1. Report
  9. Question:Define Inheritance and Polymorphism. 

    Answer
    Inheritance:When a new class is inherited from another class to extend or customize the original class, the new class is called the inheritance of the original class.Polymorphism: Polymorphism, in C#, is the ability of objects of different types to provide a unique interface for different implementations of methods.

    1. Report
  10. Question:Define overridden function? 

    Answer
    An override method provides a new implementation of a member that is inherited from a base class. The method that is overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd