Appendix

Introducing Scala

Recent years have seen many new languages created with different properties than Java, but that run on the JVM. One such language is Groovy, a dynamic language that is often used in scripting, testing, and other places where you may want to remove a lot of Java’s verbose boilerplate code. Jython is a version of Python that runs on the JVM, and Clojure is a dialect of Lisp that compiles into Java bytecode.

Scala is a functional programming language for the JVM. This chapter introduces Scala, and provides a few questions that could possibly come up in an interview if you ever have any exposure to the language.

Scala introduces some new concepts that may not be familiar to experienced Java programmers, such as functions as values, and a concise language that allows the compiler to infer the types of variables and return types of functions.

You can download Scala from the official website at http://www.scala-lang.org/download/, or you can include it as part of your build automatically by using a plug-in. If you use Maven, the following plug-in will compile any Scala source in your project’s src/main/scala directory:

<plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Scala Basics

Scala’s creator, Martin Odersky, describes Scala as “a blend of object-oriented and functional programming concepts.” ...

Get Java Programming Interviews Exposed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.