Functional Interfaces QuizJ8 Home « Functional Interfaces Quiz

OO Concepts Quiz 13

The quiz below tests your knowledge of the material learnt in OO Concepts - Lesson 13 - Functional Interfaces.

Question 1 : Functional interfaces contain only one of which type of method?
- Functional interfaces contain only one abstract method excluding abstract methods overriding one of the public methods of <code>java.lang.Object</code>.
Question 2 : Can a functional interface be annotated as such?
- A functional interface can be annotated wth the <code>@FunctionalInterface</code> annotation.
Question 3 : Which of the following callable, comparator is a functional interface from Java8 onwards?
- Both <code>callable</code> and <code>comparator</code> are functional interface from Java8 onwards.
Question 4 : Can we create functional interfaces?
- YES we can we create functional interfaces.
Question 5 : What do the primitive type functional interface specializations reduce?
- The primitive type functional interface specializations reduce autoboxing.
Question 7 : What is output from the following code snippet?

package info.java8;
public class S {
    int i = 1;
    public static void main(String[] args) {
        S s = new S(1);
    }
    S() {
        System.out.print("i = " + 1);
    }
    S(int i) {
        super();
        this();
        System.out.print("i = " + 1);
    }
}
- The code won't compile as we cannot use <code>super()</code> and <code>this()</code> together.
Quiz Progress Bar Please select an answer


What's Next?

In the next quiz we test your knowledge of lambda expressions which were introduced in Java8.