Example #1: Read from a list & write to a list
Java Way in Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 |
object ListToList extends App { val inputList = List("Java", "Scala", "Ruby") val outputList = scala. |
Java Way in Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 |
object ListToList extends App { val inputList = List("Java", "Scala", "Ruby") val outputList = scala. |
This extends Coding Scala Way – Part 1 Can you write the following code written in Java the Scala way? Java coding question on recursion and generics Q. Can you…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
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” that does not have a value. Instead of checking for “myVal !=…
Can you explain the Scala concepts applied in the following code snippets?
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
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…
Login Register 100+ Free Java interview FAQs 100+ Free Big Data interview FAQs
Q1 What is wrong with the following recursive approach to compute the nth Fibonacci number?
A1 It “hangs” for the larger values of “n” like 50.
Example #22: Fibonacci series in Scala This extends determine the nth fibonacci number using Scala. In this let’s print the Fibonacci series of length n.
Java developers need to learn Coding Scala Way. Scala way of coding is quite different & you need to unlearn Java way of coding
Question: Given a list of numbers, how will you group the numbers by how many times they occur? for example output for “List(3, 3, 4, 5, 5, 5)” is List((3,2), (4,1), (5,3)).…