Blog Archives

01: OOP vs FP with Java example – placing a trade

A Trade goes through 3 state changes – placed, filled, and settled. Let’s solve this simple problem using both OOP & …

Read more ›



02: OOP vs FP with Java example – Conversion strategy pattern

Java code to convert given input values from KM to Meter, Meter to Centimetres, etc. OOP approach using the strategy design …… Read more ›...

Members Only Content
Log In Register Home


03: Java FP composing functions example – calculate discount

FP – calculate the invoice price Invoice Price = (markedPrice * (100 – discountRate)/100) + deliveryCharge Example “f.andThen(g)” is the composition … … Read more ›...

Members Only Content
Log In Register Home


04: Java OOP vs FP – Builder Pattern

Current Balance = Initial Amounts + Credits – Debits OOP approach using the builder design pattern Creating a constructor to take … … Read more ›...

Members Only Content
Log In Register Home


05: Java OOP vs FP – Handling unchecked exceptions

int result = input / divideBy will throw an unchecked exception if divideBy = 0. OOP error handling by throwing exceptions…… Read more ›...

Members Only Content
Log In Register Home


06: Java FP – handling checked exceptions

FP error handling – checked exceptions The code below breaks the flow of execution as the input “ABC” throws a checked … … Read more ›...

Members Only Content
Log In Register Home


07: Java FP – CompletableFuture monadic chaining with examples – part 1

This extends Future Vs. CompletableFuture interview Q&As with Java 8 functional programming (i.e. FP). Q1. Why was CompletableFuture introduced in Java … … Read more ›...

Members Only Content
Log In Register Home


08: CompletableFuture monadic chaining with examples – part 2

This extends Java FP – CompletableFuture monadic chaining with examples – part 1. f and g are processed asynchronously, and …… Read more ›...

Members Only Content
Log In Register Home


09: Java FP – CompletableFuture Error Handling

handle(…) returns a result or an exception A dummy exception is thrown from “f” to demonstrate an exceptional scenario. The “java.util.concurrent.ExecutionException” … … Read more ›...

Members Only Content
Log In Register Home


Java FAQs to Fast-track & Go places

Java Interview Q&As

Top