Blog Archives
1 2 3

01: Coding “Java way in Scala” Vs “Scala way in Scala”

Example #1: Read from a list & write to a list

Java Way in Scala

Output: List(Java Programming, Scala Programming, Ruby Programming)

Scala Way in Scala: Using the “map” functional combinator

Immutable code as shown below using the “map”

Read more ›



02: Coding Scala Way – Recursion & Iterator in FP

This extends Coding Scala Way – Part 1 Example #4: FP using both recursion and functional combinator like foldLeft Can you write the following code written in Java the Scala way? Java coding question on recursion and generics 1. Define the Trait 2.… Read more ›...



03: Coding Scala Way – Lazy Eval

Example #6: Lazy initialization & evaluation of code Scala support “views“, which are collections that can be lazily evaluated. One use for views is when you need to traverse a collection of values which are expensive to compute and you only need one value at a time. … Read more...



04: Coding Scala Way – Null checks with Option-Some-None

Example #10: Null checks with “Option-Some-None”

Nulls in Scala is a code smell, and a better way to handle null values is with an “Option“, which has 2 sub classes “Some” that has a value and a “None

Read more ›



05: Coding Scala Way – FP concepts

Example #13: Explain the concepts

Can you explain the Scala concepts applied in the following code snippets?

1. Higher Order Functions: Line 10” is a higher order function as the function returns another function i.e. List[T] =>

Read more ›



06: Coding Scala Way – Reduce & Compose functions

Example #14: Reduce operations Given a list of functions as shown below, how will you go about applying all the functions in the list to each input number and sum the result of each function? For example, applying all 3 functions to first number in the list “1” … Read...



07: Coding Scala Way – Regular Expressions

Example #16: Regular Expression Regular expression (aka regex) to identify numbers in a string. Invoking “findFirstIn” and “findAll” functions of the “Regex” class. “[0-9]+”.r is a short form instead of instantiating it as new Regex(“[0-9]+”). Output Example #17: Pattern matching with regex Split the given email address into name, …...



1 2 3

Java Interview FAQs

800+ Java Interview Q&As

Top