Blog Archives
Page 2 of 5
1 2 3 4 5

05: Finding the 2nd highest number in an array

Requirements gathering Does the array allow duplicates? If duplicates are allowed, then do you need to report duplicates? For example, in {2,4, 6, 3, 6, 5}, is 6 or 5 the second highest? Analysis If duplicates are not allowed, sort the array (Arrays.sort(…)) and get the second last element, …...

Members Only Content
Log In Register Home

06: Java 8 way of File reading and functionally processing the data


#1 double colon notation ::

The new double colon (::) operator that Java 8 has to convert a normal method into lambda expression. So,

Instead of:

You can do:

#2 Why is stream::iterator used?

Read more ›

06: Understanding TimeZones with Java 8 examples

What is UTC? which stands for Coordinated Universal Time. The diagram below shows the standard time offsets of different countries. Some places observe daylight saving time (DST) during their respective summer periods. For example,

Los Angeles (i.e LA) UTC –

Read more ›

07: Java 8 API examples using lambda expressions and functional programming

Java 8 API examples using lambda expressions and functional programming. Example 1: The java.lang.Runnable interface has been made a functional interface. Output: main thread: main worker thread: Thread-0 worker thread: Thread-1 Example 2: The java.util.function package has a number of functional interfaces. … Read more ›...

Members Only Content
Log In Register Home

08: Write code to add, subtract, multiply, and divide given numbers?

A trivial coding example (i.e. a Calculator) tackled using the following programming paradigms in Java not only to perform well in coding interviews, but also to learn these programming paradigms.

Approach 1: Procedural Programming
Approaches 2 – 4: Object Oriented Programming
Approach 5: Functional Programming (Java 8)

Approach 1: Procedural

Output: result=13

Approach 2: OOP

When you have more mathematical operations,

Read more ›

Page 2 of 5
1 2 3 4 5

800+ Java Interview Q&As Menu