Java 8 Features Flashcards
1.Can you tell me the Java 8 Features
Lambda Expressions, Functional Interface, Stream API,
Default Methods, Optional Class, New Date and Time APi, Nashorn javascript engine, parallel array sorting, collectors, String Joiner Class
2.What are the Functions available in Functional Interface?
Predicate, Function, Consumer , Supplier
BiPredicate, BiFunction, BiConsumer
What is an Interface?
An interface or a protocol type that acts as a abstraction class
1.An interface have many number of abstract method
A class which implements the interface must give the implementations of that method
2. In interface explicitly we don’t want to mention the public abstract , by default abstract method in interface is public.
5.What is a Functional Interface?
A Functional interface is a interface , where it will be having only one abstract method and we can have many default and static methods.
1.We can use @FunctionalInterface Annotation to make sure that the compiler knows it.
6.Can we have default and static methods in Functional Interface?
Yes we can have default and static
methods in a Functional interface.
7.What is Marker interface?
An interface with no members or methods is known as Marker Interface.
Why Functional Interface have only one abstract method?
This Design servers several purposes , like Lambda expressions and method references.
1.Simplicity and clarity
2. Avoid Ambiquity
Enabling Lambda Expressions and Method References:
What the pre-defined functional Interface before Java 8?
1.Runnable
public abstract void run();
2.Callable
3.Comparator
int compare (T o1, T o2)
4.ActionListener Interface
public void actionPerfomed (ActionEvent e);