1.What are delegation? Give an example.
2.Whe are constructors not specified as part of an interface?
3.Some are of the view that it would be simpler to abandon the idea of abstract calsses,and instead to use an ordinary class with null or aborting implementations of methods that the user is supposed to override. Is this a good idea?
2.Whe are constructors not specified as part of an interface?
3.Some are of the view that it would be simpler to abandon the idea of abstract calsses,and instead to use an ordinary class with null or aborting implementations of methods that the user is supposed to override. Is this a good idea?
maybe I've got confused with delegation in C#, so pass.2) Interface represents the concept of 'Type' in Java
while constructor belongs to class which stands for the implementation.
We're supposed to separate type from implemenation.
From another perspective, if you provide constructor for
interfaces, how do you want to use them to instantiate object?
Writable obj = new Writable(); //? no implementation at all3) This is like saying we need only pure virtual functions for C++,
why do you need virtual functions in C++?
The same reason, that is, using inheritance to enhance reusability.
If we know that Children would do something different together with
something consistent in the same method, we're happy to define
abstract method in parent class to reduce redundant code, and to
obtain better maintanence.
i think so
Q3: Actually a more elegant and effective way to programe contains there lays, that is,Interface, Abstract Class, Class, just as Java API implies. The first one tells the property and action of an objective thing, and second one prescribe how it will be like, and the last one define what it is. Based on this idea, it is not hard for us to understand why abstract class is indispensable. In fact, when programming, we usually reduce the problem to a set of interface, then we use Abstract Classes which implement the interface to descripe possible actions of this kind of problem; each Abstract Class for each possible actions. and finally we define exactly how the problem is respectively solved.
2,whe这个单词?
3.SAX就提供了一个不实现任何功能的DefaultHander,你想要什么覆盖什么,不要就不管.比起抽象类更方便.util的集合类库也是这样实现的,你不想实现的功能就抛异常..好不好不知道,只知道方便
We must study english more hardly.