Results 1 to 5 of 5
Thread: Abstract Class
- 01-30-2008, 09:32 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 17
- Rep Power
- 0
Abstract Class
I have to take a design decision. I have a super class that is being inherited by a couple of classes. Working fine.
If I declare it Abstract, it works as it is. I understand that one cannot instantiate Abstract class, but I don't need to do that.
Is it ok to declare it Abstract?
Thanks.
- 01-30-2008, 09:54 PM #2
Abstract classes
Hello gapper.
Classes are defined to be abstract if you know that instances cannot or should not be created from them. Like the class, Animal, should be abstract because we cannot create an animal with no information about it. But, we can create a Dog, which is a subclass of Animal. A family of classes containing abstract classes are usually designed so to prevent illegal usage and logical errors.Eyes dwelling into the past are blind to what lies in the future. Step carefully.
- 01-31-2008, 02:18 AM #3
Unless you have one or more abstract methods there isn't much point in declaring it abstract.
For discussion see Abstract Methods and Classes.
- 01-31-2008, 12:45 PM #4
I am afraid I would disagree. Even if there are no abstract methods there may be a point in declaring it abstract. As Tim says the point of abstract is that the class cannot ( in the case of abstract methods) or should not be instantiated directly. I may choose to have a super class that has only concrete methods that will be inherited by, and used by, sub classes but I do not wish to allow the superclass to be instantiated directly, i.e. it is an architectural decision.
-- Hope that helps
- 01-31-2008, 01:25 PM #5
Member
- Join Date
- Jan 2008
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
Can this be done using abstract class??
By romina in forum New To JavaReplies: 6Last Post: 03-02-2009, 12:46 PM -
Abstract Class with Static Methods
By bugger in forum New To JavaReplies: 7Last Post: 09-05-2008, 12:20 AM -
Interface Vs Abstract Class
By javarishi in forum New To JavaReplies: 5Last Post: 06-15-2008, 05:43 AM -
what is the Priority for execution of Interface class and a Abstract class
By Santoshbk in forum Advanced JavaReplies: 0Last Post: 04-02-2008, 07:04 AM -
Abstract Class question
By maa11235 in forum New To JavaReplies: 1Last Post: 01-05-2008, 10:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks