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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Jul 23, 2014, 8:25 PM EDT
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.
Rajesh Pathakoti161 reputationPosted Jul 23, 2014, 9:51 PM EDT
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 23, 2014, 11:04 PM EDT
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.