File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes why we need to declare a class abstract?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why we need to declare a class abstract??" Watch "why we need to declare a class abstract??" New topic

why we need to declare a class abstract??

Puneet Mittal
Ranch Hand

Joined: Dec 18, 2007
Posts: 45

hi please tell me what is the need of declaring a class abstract???
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45255
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

Joined: Aug 08, 2007
Posts: 202
when you want to leave that a subclass implements the methods abstract.

Brazil - Sun Certified Java Programmer - SCJP 5 About Java - Update every Week.
Guide SCJP - tips that you need know
I agree. Here's the link:
subject: why we need to declare a class abstract??
It's not a secret anymore!