Hello Sir...
What are reason i can't create object for abstract class?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 24, 2014, 3:04 AM
An abstract class is a class that contains some methods that are not implemented yet. They must be implemented with in derived 'concrete' class. So We can say , an abstract class is 'incomplete'. If you were to instantiate one, it will have 'holes' where those methods(empty) are called. The framework is preventing you from building a class with holes in it. Hence you can only instantiate a concrete class.
also refer
http://msdn.microsoft.com/en-us/library/ms173150.aspx
hope this will help you.
Rajesh PathakotiPosted Jul 24, 2014, 1:51 AM
For example, In a normal class we have 2 methods Add() and Delete(). Now Client asked one more method is Update(). So normally we can do this by inheritance we can create new class and deriving from old class. But here we are creating once again class.
So abstract class gives this scenario by adding new method without changing previous functionalities and without creating new class.
So finally when changes came from client then we can do easily and maintance of code also very easy. This is the real time scenario of using abstract classes
Pradeep ShetPosted Jul 24, 2014, 12:25 AM
Because abstract class can have both method with and without implementation. And if you have any method which is abstract or without implementation then what is the use of creating an object. So compiler wont allow to create an object for this type of classes.
I hope this helps you..if yes marked it as answered.