Core java interview Questions You'll Most Likely Be Asked (Second Edition)


Download 1.52 Mb.
Pdf ko'rish
bet164/171
Sana07.01.2023
Hajmi1.52 Mb.
#1081886
1   ...   160   161   162   163   164   165   166   167   ...   171
Bog'liq
Core JAVA Interview Questions Youll M...

Section 2– Java 8
Func onal Interfaces
What is a functional interface? How can you create a
functional interface?
Explain the java.util.Function package.
Explain the java.util.function.Consumer interface with a code
sample.
Explain the differences between the Supplier and Consumer
interfaces.
What is the output of the following code snippet?
Which in–built functional interface would you use to convert a
String to uppercase?
Is the code below valid? Explain.
Name some pre–Java 8 interfaces that are made functional
interfaces by Java 8.
Why are primitive specializations of the in–built functional
interfaces like IntSupplier, BooleanSupplier, etc. added by
Java 8?
Where are the built–in functional interfaces commonly used?


207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
Lambda Expressions
What is a lambda expression? What are the benefits of using
lambda expressions?
How are lambda expressions and functional interfaces related
to each other?
Explain the syntax of a lambda expression.
Give some examples of lambda expressions.
Write a code sample that creates a Functional interface and
use a Lambda expression to implement it.
Explain with a code sample how the same functional interface
can be implemented differently using different lambda
expressions.
Identify the error in the following lambda expression and how it
can be fixed.
Is the following code valid? Explain.
Write a functional interface for which the following lambda
expression would work.
Explain how you can create a new Thread using lambda
expression.
Streams
Explain the different ways in which you can create a Stream.
Explain the Stream filter operation with a code sample.
Explain the types of Stream operations.
What is a parallel stream? Explain with a code sample how
you can create a parallel stream.


221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
How can you convert a Stream back to a Collection?
What is the output of the following code snippet?
What is the difference between a Stream and a Collection?
Suppose you have a List of String values. You want to create a
new List that eliminates the duplicates from the original List
and has the String values in uppercase. How will you achieve
this via Stream operations?
Is it possible to convert an array to a Stream? Explain.
Suppose you have an Employee class as follows:
And suppose you have a List of Employee objects as follows:
How can you create a new List is sorted based on the
Employee salary using Streams?

Download 1.52 Mb.

Do'stlaringiz bilan baham:
1   ...   160   161   162   163   164   165   166   167   ...   171




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling