Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 4

Given:

Which two interfaces can be used in lambda expressions? (Choose two.)

    Correct Answer: A, E

    To be eligible for use in lambda expressions, an interface must be a functional interface, which means it should have exactly one abstract method. MyInterface1 has one abstract method 'int method() throws Exception' and, as the private method pMethod() is not considered in the functional interface, it qualifies. MyInterface4 also qualifies because it has one abstract method 'void method()'. The other interfaces either have multiple abstract methods or do not meet the criteria for being a functional interface.

Discussion
Eivind123456789Options: AD

Allowed with private methods in interfaces if implemented. Allowed with static methods (private and public) if implemented.

Ashan_OzlovOptions: AD

A allowed D the equals different signature to Object class equals

lenicoulibalyOption: D

D is the correct answer because D got only one abstract method A is a compilation error because only static and default method can be none abstract in an interface B Be could not be used in lambda expression because B got two abstract methods C is a compilation error because static methods in interface could never be abstract. They need to be implemented in the interface E is a compilation error because only static and default methods could be implemented in an interface