Amazon Interview Question
Software Engineer / Developerspublic: So you can use in polymorphic variables...Use as composition and call all public methods...Use case when you do not implement the interface but contain it.
static: Since with an interface, you do not associate an instance...instance is more implementation specific
final: Again, if some app modifies members of the interface, you cannot track down whom else it may affect
Its an interface, hence can have only constants. Hence the final.
First of all interface by its name should have abstract methods. Only set of method signature that's all. Hence all the variables are made static as they are not really a part of the class.
As the variables are static they should be accessible from anywhere to any client. Hence they are made public.
Dosent makes sense if you make them private because interface has no method bodies so who will then use these variables ......
- abid January 22, 2009