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


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

Method References
What is a method reference? What are the benefits of method
references?
What are the different types of method references?
Give an example of static method reference.
Consider the following Shape class:
What changes are required in this class in order to make the
code below valid?
Explain what type of method reference is String::toUpperCase.
DateTime API
Explain what is wrong in the following code snippet and how
you can fix it.


233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
Explain with appropriate code samples the different ways in
which you can create a LocalDate.
Explain with a code sample how you can check if a date is
before another date.
Explain the ZonedDateTime class.
What will be the output of the following code snippet?
How can you obtain the day of the week corresponding to a
date using the Java 8 DateTime API?
Explain the differences between the Period and Duration
class.
Suppose you have a String date in the yyyy/mm/dd format.
How can you obtain a LocalDate object corresponding to such
a date?
What is the output of the following code snippet?
Explain how you can find out if a year is a leap year using the
new DateTime API.
Sta c and Default Interface Methods
What are static and default methods? Why were they
introduced by Java 8?
What is the difference between an abstract class and an
interface after Java 8?
Write a code sample that demonstrates a default method.
What is the difference between a static and a default interface
method?
Identify the error in the following code snippet and explain how
it can be fixed.


247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
Op onals
What is an Optional and why was it added by Java 8?
How can an Optional be created?
Explain the Optional.ifPresent method with a code sample.
What is the difference between the orElse and orElseThrow
method?
What will be the output of the following code snippet?

Download 1.52 Mb.

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




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