Showing posts with label .net interview questions and answers. Show all posts
Showing posts with label .net interview questions and answers. Show all posts

Sunday, February 7, 2021

Dot net Interview Questions and Answers 2021

Note: I will Update the answers later    

Ans:  Object-Oriented Programming (OOP) All Programming Language will support this OOP there are Three main concepts in OOP
   a)Encapsulation
   b)Abstraction
   c)Inheritance
   d)Polymorphism
Encapsulation  :
Encapsulation is the process of Keeping the data and method together into Objects
OR
Simple Putting Together into one simple class Like.
OR
Means that a group of related properties, methods, and other members are treated as a single unit or object.
_____________________________________________________________
Class My Class
{
public MyClass()
{

}
int a;
int b;
Public void GetAdd()
{
 int C=a+b;
}

}
____________________________________________________________

Abstraction : Hiding the Data
Inheritance:
Inheritance Enables  you to Create Class that Reuses
OR
Acquiring the Properties of Base Class(Parent Class)
OR
Means Provide Further Implementation ,Reusing of  Base Class
__________________________________________________________
Public Class MyClass
{
Public MyClass()
{
}
int a;
int b;
Public void GetMyMethod()
{
int c=a+b;
}
}
Public Class MyChildClass : MyClass
{
 Public MyChildClass()
{}
}
C# Doesn't Support Multiple Inheritance By Using Interfaces We Can 


Polymorphism
Polymorphism means same operation may Behave Differently in Different Classes

Example of Compile Time Polymorphism: Method Overloading
Example of Run Time Polymorphism: Method Overriding

Method Overloading- Method with same name but with different arguments is called method overloading.
- Method Overloading forms compile-time polymorphism.
- Example of Method Overloading:
class MyClass
{
Public string hello()
{
return "Hello";
}
public string hello(string s)
{
return "Hello"+S.Tostring();
}
}

Method Overriding- Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass.
- Method overriding forms Run-time polymorphism.
-Virtual Key word is required for Overriding
- Example of Method Overriding:
Public Class MyClass
{
virtual void hello()
{
Console.WriteLine(“Hello from MyClass”);
}
}
Public Class MyChildchild : MyClass
{
override void hello()
{
Console.WriteLine(“Hello from Child”); }
}
}________________________________________________ 

2.What are value types and reference types? 
A: Integer is a value type. The string is a reference type.

3. What is the use of IS and AS Keywords?
 A: Typecasting.

4.What are the generic delegates and what is the use of that?

5.What is the use of extension methods and anonymous methods? 


6.What is the Static class? 

7.Can we use the "this" keyword in the Static class? 
A: No 

8.What is the difference between read-only and constant?

9.What is the difference between var and dynamic?

10.What is the difference between Interface and abstract?

11. What is the use of async and await keywords?