Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

are the staements true or false? An Interface, say IName1 can be \'extended\' (I

ID: 3592537 • Letter: A

Question


are the staements true or false?

An Interface, say IName1 can be 'extended' (Inheritance) by Multiple Interfaces, say IName2 and IName3. Classes which implement IName2 or IName3 will have to implement all the method declarations of IName1 along with of course IName2 or IName3's. Starting from Java 8, if the contract of say IName1 changes, the Class implementing it, say CName1 doesn't have to implement the change, as long as IName1 gives the implementation/method body of the new method starting with the 'default' keyword. 8. 9. 10. From item 9, CName1 can call the 'default' method. Hint: IName1.super.defaultMethNamel) 11. From item 9, CName1 can give its own implementation/method body of the new method

Explanation / Answer

Answer 8: True

Becuase interface is the collection of abstract methods, so classes which implement those interfaces need to implement all of the methods decarations of the interfaces.

Answer 9: True

Prior to java 8, we can have only method declarations in the interface, so the classes implementing those interface need to implement all methods declared in the interfaces, that's why we can not extend the interfaces, because every time we need to change the all classes implementing that interfaces. But from java 8, we can have default methods and static methods in the interfaces, and when a class will implement interface , it is not mandatory to provide the implementation for default methods of the interface.

Answer 10. True

Yes, class can call the default method by using super keyword.

Answer 11. True

As we know java supports multiple inheritance, that is a class can implement more than one interface, and each interface can define default method with same method signature, therefore, the inherited methods can conflict each other. In order to fix this class, we need to provide default method implementation.