OOP’s or Object Oriented Programming is programming model which involves classes and objects. It focuses on objects more rather than logic.
OOP’s can be achieved by making class and it’s object and thus making it’s method, which can be accessed by object of class.
OOP’s consists of several concepts,
1. Encapsulation
2. Polymorphism
1. Static Polymorphism
2. Dynamic Polymorphism
3. Inheritance
4. Abstraction
5. Interface
1. Encapsulation : Encapsulation is a concept of of OOP’s programming which enables the programmer to bring multiple methods or multiple units of code into a single unit. It’s example is class.
using System;
namespace Encapsulation{
// Example of Encapsulation.
class Encap{
public int val;
public void greet(){
val = 10;
Console.WriteLine("Hello User. Value is ",val)
}
public void greet1(){
Console.WriteLine("An example of Encapsulation.")
}
}
class Program{
Encap e = new Encap();
e.greet();
e.greet1();
}
}
2. Polymorphism : Polymorphism is another feature of OOP. According to this two or more methods can have same name but different forms. We will learn more about this in the later on topics.
3. Inheritance : Inheritance is a feature with which a class can inherit the properties of another class according to their access modifiers. There are mainly three types of Inheritance,
1. Single Inheritance
2. Multiple Inheritance
3. Multi-Level Inheritance
4. Abstraction : Abstraction helps the programmer to achieve data hiding. In Abstract classes may only method names can be present and it’s definition can be written in another class through inheritance.
5. Interface : Interface works on the principle of abstraction. If a class is of interface type then all of it’s methods will be abstract whose definition will be written in another class with inheritance.