Programming > Research Paper > Java8 Innards.txt (All)
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<String, String> f) { return f.apply("Welcome "); } @Override public void add(Consumer<Integer> 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]
Last updated: 1 year ago
Preview 1 out of 4 pages
Buy this document to get the full access instantly
Instant Download Access after purchase
Add to cartInstant download
We Accept:
Connected school, study & course
About the document
Uploaded On
May 21, 2021
Number of pages
4
Written in
This document has been written for:
Uploaded
May 21, 2021
Downloads
0
Views
131
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·