This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line! See this thread for details.
I have a inheritance question. Here i have Interface I1 and I2 (that extends I1 and overrides its default method). In Class1 , i try to implement both I1 and I2 . Since I2 override I1's method. It inherited I2's overridden method and the Test class prints 2.
I expected it to give a compiler error in Class1 about inheriting duplicate method . But it did not .Can you please explain this a bit more ?
It is because interface I2 is overriding 'someMethod' from interface I1. I think that 'implements' statement for Class1 mentioning implementing interface I1 is redundant, since Class1 implements it implicitly via implementing interface I2, which is extending I1. Class1 would have compiler error stating that it should provide its own implementation of 'someMethod' method, if interface I2 would not be extending interface I1.