You have an FirstInterface reference. When you do this you only have access to the defined interface methods. There are benefits to creating a reference like this, but like in everything else there are negative tradeoffs.
Try this and see if you can access any method in StaticTest:
Object o = new StaticTest(); [ September 11, 2006: Message edited by: Robert Hill ]
So a is the reference of type FirstInterface type and since StaticTest class implements FirstInterface variable a should be able to hold the reference of StaticTest class but when i try to make a call to method helloIndia() which is written in StaticTest my program is not compiling... trying to figure out why???
I already answered it, perhaps it is too vague, so I will try again.
The only methods a reference can see are those of its own type and parents. FirstInterface, in this case can access its own method and the methods of Object. That is it. FirstInterface knows nothing about any classes that could implement it, and why should it? How many classes could potentially implement it?
What you are doing is called polymorphism, I suggest you read more on it, and its implementation in Java. [ September 11, 2006: Message edited by: Robert Hill ]