Object o = () -> {System.out.println(“Example”); }; Object o can be replaced
with ?
Runnable r--correct
Lambda Expressions are based on
Functional Programming--correct
public interface Adder { String add(Function f)
...
Object o = () -> {System.out.println(“Example”); }; Object o can be replaced
with ?
Runnable r--correct
Lambda Expressions are based on
Functional Programming--correct
public interface Adder { String add(Function f); void add(Consumer f); }
public class AdderImpl implements Adder {
@Override
public String add(Function f) {
return f.apply("Welcome ");
}
@Override
public void add(Consumer f) {}
} On calling add() method as described below, String r = adderImpl.add(a -> a +
" lambda"); System.out.println(r);
Runtime error--correct
Lambda Expressions in Java allow us to treat
Code as data--correct
which of the following are not valid lambda expressions?
None of the options--correct
Parameter types be inferred in Lambda expressions ?
True--correct
Which of the following is correct about Java 8 lambda expression?
Both--correct
Following lambda expression is valid (x, y) -> return x + y
False--correct
public class App{ public static void main(String [] args){ String
name="WelcomeJava"; Runnable r1=() -> System.out.println(name); String name1="";
name1=name.toUpperCase(); Runnable r2=() -> System.out.println(name1); r1.run();
} } What is the o/p of the above program?
compilation error--correct
Which of the following are valid uses of lambda expressions?
public void execute(Runnable r){ r.run(); } Execute(() -> {});--correct
Which of these interfaces are functional interfaces?
public interface Cards{ int totalCount(int a, int b); }--correct
[Show More]