50% found this document useful (2 votes)
1K views3 pages

Java8 Innards FrescoPlay

Lambda expressions allow treating code as data and are based on functional programming. Several functional interfaces are introduced in Java 8 including interfaces for operations with different parameters and return types. Streams API introduced in Java 8 allows processing collections of elements sequentially and supports intermediate and terminal operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
1K views3 pages

Java8 Innards FrescoPlay

Lambda expressions allow treating code as data and are based on functional programming. Several functional interfaces are introduced in Java 8 including interfaces for operations with different parameters and return types. Streams API introduced in Java 8 allows processing collections of elements sequentially and supports intermediate and terminal operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Following lambda expression is valid (x, y) -> return x + y


False
2.Lambda Expressions in Java allow us to treat
Code as data
3.which of the following are not valid lambda expressions?
None of the options
4.Which of the following are valid uses of lambda expressions?
public void execute(Runnable r){ r.run(); } Execute(() -> {});
5.Lambda Expressions are based on
Functional Programming
6.public interface Adder {}
Runtime error
7.Object o = () -> {System.out.println(“Example”); }; Object o can be replaced with ?
Runnable r
8.Parameter types be inferred in Lambda expressions ?

m
True

er as
9.public class App{}

co
compilation error

eH w
10.Which of the following is correct about Java 8 lambda expression?

o.
Both

rs e
11.A functional interface acts as target types for which of the following?
ou urc
All the options mentioned
XLambda expression
12.A FunctionalInterface annotation (@FunctionalInterface) is necessary for making an interface a
o

functional interface
aC s

False
vi y re

13.Which of the following functional interface represents a function that accepts an int-valued
argument and produces a long-valued result?
IntToLongFunction
14.Which of the following functional interface represents an operation that accepts an object-valued
ed d

and an int-valued argument, and returns no result?


ar stu

ObjIntConsumer<T>
15.Which of the following functional interface represents an operation that accepts a single input
argument and returns no result?
16.Which of the following functional interface represents an operation that accepts a single input
is

argument and returns no result?


Th

Consumer<T>
17.What functional interface would you use for the following? No parameters , returns a value
Supplier
sh

18.Which of the following functional interface represents an operation upon two long-valued
operands and produces a long-valued result?
LongBinaryOperator

19.Which of these interfaces are functional interfaces?

This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:10:15 GMT -05:00

https://www.coursehero.com/file/77195709/Java8-Innards-FrescoPlaydocx/
public interface Cards{ int totalCount(int a, int b); }
20.Below code includes a valid Functional Interface ? package functionalInterfaceExample;
True
21.Stream operations in java 8 can be divided into
All
22.Terminal operation produces another stream as its output
False
23.If you wanted to process a stream of names, extract the male names, and store them in a
new List, What is the appropriate operation to be used?
Stream.collect
24.The newly introduced Streams API is available in which package of java 8
Java.util.stream
25.Stream operation iterations are internal over the source of elements
False
26.Each pipeline ends with a

m
Terminal operation

er as
27.Which of these does Stream filter() operates on

co
Predicate

eH w
38.Which of the following is valid Stream operation type

o.
Both
rs e
39.Identify intermediate and terminal operations in the code. double average = roster
ou urc
.stream() .filter(p -> p.getGender() == Person.Sex.MALE) .mapToInt(Person::getAge) .average()
.getAsDouble();
Intermediate: filter, mapToInt Terminal: average
o
aC s

40.Repeating annotations can be retrieved using


vi y re

getAnnotationsByType()
41.Type annotation used to depict non blank string value
@NotBlank
ed d

42.Repeating annotations can be added with below 2 declarations


ar stu

Declare a repeatable annotation type


Declare the containing annotation type
43.On which of these does annotations can be used on in Java 8
All the options mentioned
is

44.Optional type validation can be used to substitute runtime validations.


Th

False
45.In Functional Reactive Programming, we pull the stream of data
False
46.Library used to write reactive programs in java
sh

RxJava
47.Which method is used to connect the consumer to the source in reactive programming
subscribe()
48.Which class can be used Instead of System.getCurrentTimeMillis() to get a date and time in
Java 8

This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:10:15 GMT -05:00

https://www.coursehero.com/file/77195709/Java8-Innards-FrescoPlaydocx/
Clock
49.Which package contains Date/Time (JSR 310) API in Java 8
Java.time
50.Reactive Programming deals with
asynchronous data
51.DateTimeFormatter formatter=DateTimeFormatter.ofPattern("EEEE",Locale.US);
System.out.println(formatter.format(LocalDateTime.now()));
Choose the correct output.
Friday
52.import java.util.Optional;
public class App { }
Compilation error
53.Which of the following can be a valid input for jdeps dependency analyzer?
All the options mentioned
54.Example of functional interfaces in Java 8

m
Both

er as
55.Which methods preserve parameter names in Java bytecode (through reflection API)

co
specify -parameters during compilation

eH w
56.Which of the following class implements an encoder for encoding byte data using the Base64

o.
encoding scheme in Java8?
Base64.Encoder rs e
ou urc
57.In java 8, Static methods cannot be added to a Interface
False
58.We need to override which Predicate method in Java 8. Which is the right method call
o

test(T t)
aC s

59. LocalDate date1 = LocalDate.now();


vi y re

LocalDate date2 = date1.plus(1, ChronoUnit.MONTHS);


Period period = Period.between(date2, date1);
System.out.println("Period: " + period);
ed d
ar stu

Period: 1
is
Th
sh

This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:10:15 GMT -05:00

https://www.coursehero.com/file/77195709/Java8-Innards-FrescoPlaydocx/
Powered by TCPDF (www.tcpdf.org)

You might also like