Java 8 Questions.
what is functional interface. Ans :- An interface defined with only on abstract method. That interface can have multiple default and static methods. Supplier, consumer and predicate are the functional interface provided by 8. Supplier FI can used as factory pattern to create object using get method of that interface. i.e. import jdk.nashorn.internal.objects.annotations.Setter; import java.util.UUID; @Setter public class Car { UUID id; String name; } public class MarutiCar extends car { } import jdk.nashorn.internal.objects.annotations.Setter; import java.util.UUID; import java.util.function.Supplier; public class CarSupplier { private static <T extends Car> T getCar( final Supplier<T> supplier, final String name) { T car = supplier.get(); car.setId(UUID.randomUUID()); car.setName(name); return car; } public static void main(String args[]) { MarutiCarr car = getCar(MarutiCar:: new , "Maruti C