Rajat Bhatia wrote:inside getHello method we return an instance of HelloInterface interface
No, you return an instance of an anonymous inner class that implements the HelloInterface. If you look at the results of compiling Text.java, you will find that two class files are created, one for the outer class and one for the inner class.
When I tried printing hello reference,it showed that the reference points to an object of Test type.
Look more closely. What do you see? (hint: $1)
And welcome to the Ranch, Rajat! For your future posts, please learn to UseCodeTags <- link to retain code formatting for readability.
There are no new questions, but there may be new answers.