Not an Advanced question. It's about the basic language.
Originally posted by Akhilesh Trivedi:
1. Is constructor for an abstract class really necessary?
Assuming the abstract class is going to be subclassed by a concrete subclass, then the abstract class constructor is called when the concrete subclass is instantiated. The subclass cannot know how to initialise its superclass, so this makes sense.
For "utility classes", which are declared abstract because they contain only static methods and are not expected to be instantiated,
Java's insistence on having a constructor (default or explicit) is a bit annoying. It might have been nice if the language allowed classes to be declared "abstract final" and such classes were excused from having a constructor. Perhaps Java's designers were trying to discourage "utility classes", which aren't good OO design.
Originally posted by Akhilesh Trivedi:
2. Why do we have a via-object-access to invoke methods when we can, and are preferred to do it by class name?
You mean for static methods? As far as I can see, it's just a stupid feature of the language. No good reason.
[ October 04, 2006: Message edited by: Peter Chase ]