Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why we need to declare a class abstract??

 
Puneet Mittal
Ranch Hand
Posts: 45
Eclipse IDE Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi please tell me what is the need of declaring a class abstract???
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you have read this FAQ? You don't "need" to declare a particular class abstract, but there are occasions when you want a "place" in your inheritance hierarchy where you don't want anybody creating instances, or you might have methods which will have such variability that you want them abstract too.
ExampleNow, some behaviour of buses and cars might be the same, some might be different, but you don't want any "Vehicle" objects. So you would probably declare Vehicle abstract. I think, you write the name of abstract classes in italics in a UML diagram.
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you want to leave that a subclass implements the methods abstract.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic