Six Important C# Interview Questions & OOP Concepts
1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
2) What is Encapsulation? How can we achieve?
A) Wrapping STATES and BEHAVIOURS are called as ENCAPSULATION. Or Binding VARIABLES and METHODS is called as ENCAPSULATION. By implementing class we can achieve ENCAPSULATION.
3) What is abstraction? How can we achieve this?
A) Abstraction means HIDING.
Abstractions are 2 types.
1) data abstraction:-
Hiding unwanted data is called as data abstraction
2) Method abstraction:- Invoking the required method and hiding unwanted method is called as method abstraction. With the help of FUNCTION OVERLOADING, we can achieve Method ABSTRACTION.
4) What is Inheritance? Types of Inheritance?
A) Inheriting or deriving members from one class to another class is called as INHERITANCE. C#.Net will support 5 types of Inheritance. They are
1. Single Inheritance
2. Multi-level Inheritance
3. Multiple Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance.
5) Polymorphism:
Polymorphism means one name, many forms are called as Polymorphism
there are two types of Polymorphism
1)Overloading (compile Time Polymorphism)
2)Overriding (Run Time Polymorphism)
1)Overloading -Means the same name but different signatures(parameters)is called as Overloading
2)Overriding -:Means Same name and same Signatures(parameters)is called as Overriding
1) Is C#.Net will support multiple Inheritance?
A) In C#.NET multiple inheritances is not possible by using classes, which is possible with the help of INTERFACES.
2) What is a sealed class? When we will go for a sealed class?
A) While defining a class, if we have used ―sealed‖ keyword then that class can be called as SEALED CLASS. It cannot be inherited. Whenever we want to restrict to inherit a class we can go for sealed class.
3) Static Class:
1)A static class is declared with the help of a static keyword
2)A static class can only contain static data members, static methods, and a static constructor
4)Static Variable:
1)A static variable is declared with the help of a static keyword.
2)Static variables are accessed with the name of the class, they do not require any object for access.
5)Static vs dynamic
Static--
1)when a variable can't change its value during run time
2)In Static variable value assigned directly in a program itself.
Eg=: int a=313;
Dynamic :
1)when a variable can change its value during run time
2)In dynamic variable value assigned/taken from the user.
eg=: int a;
7)What is Boxing and Unboxing?
1)Boxing-Converting a value type to reference type is called Boxing.
eg-int a= 123;
object obj=(object)a //Boxing
2)Unboxing-Converting a reference type to value type is called UnBoxing.
obj=123;
a=(int)obj //InBoxing
Nice article. It's very helpful to me. Thank you for share with us. Can you please check my article Add dynamic body class in angular project
ReplyDeleteNice article. It's very helpful to me. Thank you for share with us. Can you please check my article Add dynamic body class in angular project
ReplyDelete