This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
interface is implicitly abstract.but it allows to declare a class inside r it.like this,
above program will print Hai. but it violates the abstract concept. explain me. [ Jess added UBB [code] tags to preserve whitespace, check 'em out! ] [ August 07, 2003: Message edited by: Jessica Sant ]
actually Krishna, how you have it written, it won't compile because of a couple reasons: 1- you've got a little typo in the name of your inner class -- it should be Inner not inner when you try to call it in your main() method. 2- you declared a non-static innter class so you have to instantiate the outer class in order to get access to the inner class. BUT as you know... you created the outer-class to be an interface.... so it can't be instantiated. That's why it won't compile -- this line won't work: inter.Inner.method() So, how do you fix it? One option is to declare the inner class and its method to be static. That way you don't need to instantiate the outer class or the inner class in order to access the method.
The other option is to implement the interface, instantiate that new class, create an instance of the inner class and execute the method. How would you write the code to do it this way?