Description: We offer Best C# Training, .NET Training and SQL training If you need training on any of the technologies please contact us.
c# training (14) .net training (11) sql training (10)
In my opinion the major advantage of OOP is code reusability , maintainance and extensibility. Inheritance,Polymorphism and Encapsulation helps to achieve this. Lets see with a simple example.
Lets make a virtual zoo. We got a tiger and lion. We are going to add the animals to a list and have them make their sound one by one. I made an Animal class with Breath function and a property animal name. Since all the animals breath, and all of them got a name we can reuse them by inhertiance . Then there is a virtual method(behavior) named MakeSound which will make the sound of the animal and demonstrate a vital concept in OOP called polymorphism . The child classes can implement them with their own Mak
You will hear a growl. That is the beauty of polymorphism. Compiler knows that first animal object is type of Tiger and it delegates the call properly. This is a fundamental and very important concept in OOP. As you can see, its so easy to add a new animal to your Zoo. Just derive it from the Animal class and implement the Animal's MakeNoise. Because breathing is already taken care of, you don't need to worry about that.