Tuesday, September 13, 2016

Top 5 interview questions on OOPS

1.Fundamental elements of OOPS
Abstraction
hide certain details and only show the essential features of the objec



,Encapsulation,   inheritance, polymorphism

1. What Is difference between Abstanct , Encapsulation


2.Explain the difference between a class and an object.

 class as a template of the object.  it describes all the properties, methods, states and behaviors that the implementing object will have.
 an object is an instance of a class, and a class does not become an object until it is instantiated.


3.Explain the difference between managed and unmanaged code.


Managed code
• It  is a code created by the .NET compiler.
•  It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime),
4. What is CLR
5. CLR stands for  Common language runtime

• CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.

Unmanaged code
•  is directly compiled to native machine code and depends on the architecture of the target machine.
• It is executed directly by the operating system.
•  In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually.

In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.

4.Explain the difference between boxing and unboxing. Provide an example.

Boxing :is the process of converting a value type to the reference type
unboxing : is extracting the value type from the reference type.

While the boxing is implicit, unboxing is explicit.
Example (written in C#):
int i = 13;
object myObject = i; // boxing
i = (int)myObject; // unboxing

3.Explain the differences between an Interface and an Abstract Class in .NET.


5.What is a delegate
A delegate in .NET is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. In addition, we could use delegate to create custom event within a class. For example,