Thursday, June 16, 2005

java notes

results from the worked out examples,

Facts about interface:
======================
1.all methods of interface are abstract.
2.all the members of interface are static & final.
3.interface cant have mehod with definition.
4. A class can extend one class but can implement many interfaces..
5. A class can extend more than one interface.
6. An interface only can extend another interface.
7. An interface can not be private/protected.
8. An interface can extend another interface and not a class.
9. Assume an interface i, class c have a method sum(). If a class implements
i, extends c means, it needs not to define the method sum() of i. (if class c
omits the body, then it shd. Also, the remaining methods of i, shd be defined
the body.)
10. An interface can be defined in side a class. (Nothing wrong, a nested
class can implement that interface)


Facts about abstract
===================
1.If an abstract class defines body of a method, the extending class needs not
to implement it again
2. If an abstract class doesnt define body of a method, then extending class
should implement it.
3. If there is a class having no method definitions, the extending class
should implement the body...(similiar to Abstract class)
4. 'abstract' key word insists that 'you cant create object for the class'
5. abstract class can have reference variable but not objects(initialization/
using new keyword)

Interface Vs Abstract class:
=============================
1.An interface has adv over abstract, since it helps in achieving multiple
inheritance.
2.Interfaces are slow as it requires extra indirection to to find
corresponding method in in the actual class. Abstract classes are fast.
3. for interface its possible to create reference. But for abstract classes it
is not.

No comments: