Monday, February 26, 2007

Interface in Java

Interface juz says 'what the class can do',but doesnt say 'How it can do'.Interface can be implemented by any class in the Hierarchy.

Unlike abstract classes , interface can only have abstract methods.

Interface methods are implicitly public and abstract....No need to explicitly declare them as 'public' or 'abstract'.

Interface variables are implicitly public,static and final. So no need to declare those things explicitly.If once initialised within the interface they become read only , and cannot be modified.

Interface methods must not be static.

Interface can extend one or more interfaces, and only interfaces, and not classes . It cannot implement interfaces or classes.

No comments: