Scala Flashcards
What is the JDK and what does it let us do?
JDK stands for Java Development Kit. It is a package for developing Java based software. It will take our source code and convert them to a format that the JRE or JVM can execute. It includes things such as the Debugger for finding errors and the Java Compiler for compiling our code. Java developers will use the JDK as an environment to develop, compile, and run java applications.
What is the JRE and what does it let us do?
JRE stands for Java Runtime Environment. The JRE is used to RUN your java program. The JRE contains classes and the JVM which will be used to run your Java Program.
What is JVM and what does it let us do?
JVM stands for Java Virtual Machine. It provides the Java Runtime Environment for which java bytecode (.class java file) can be executed. The tasks of the JVM include loading, verifying, and executing the code and this is done line by line.
What is Git?
Git is a version control system that lets you track and make changes to your files. It keeps a record of what you have done and lets you revert to specific versions of your files. Git allows for easier collaboration between multiple people because it allows you to keep all your files merged into one source. Git allows you to save and develop on parallel versions of your code base.
What is Github?
Github is a hosting service that lets you manage your git repositories. It provides a graphical interface to let you see and manage your projects.
How does scala relate to Java?
Java and Scala are both Object Oriented programming languages. Scala like Java also utilizes the JVM meaning scala code will be converted to the same bytecode as java, thus they share the same memory space, types and JVM.
Is scala statically typed or dynamically typed?
Scala is a statically typed language. Statically typed languages mean that types are checked at compile time as opposed to run time. So for example if you have an Int value it will ensure that the value is used correctly throughout the program and at runtime nothing other than an int can be in that values memory location.
Do we need to declare type for Scala?
Scala has a type inference system meaning that if you declare a variable to be of value 1 the compiler will know that the variable is type int. With this system, it is not necessary to declare types although there will be times where you might need to declare types explicitly for better code readability.
What are integer types in Scala?
Integer types are represented in scala by int, long and short. Int is a 32 bit two’s complement integer where as short is a signed 16 bit two’s complement integer and long is a 64 bit two’s complement integer.
What are decimal types in Scala?
Decimal types are represented by floats and doubles with float being 32 bits and double being 64 bits.
What is the difference between val and var?
The difference between val and var is that val makes a variable immutable and var makes variable mutable. Val is similar to that of final in java where when declared it cannot change while a var variable can change throughout a program’s lifetime.
What is a pure function?/What is a side effect?
A pure function doesn’t depend on and doesn’t modify the states of variables out of its scope. If you call pure functions with the same set of arguments you will always get the same return values. They do not modify the arguments which are passed to them.
Why do we make use of programming paradigms like Functional Programming and Object Oriented Programming?
Functional programming helps us solve problems in a simpler way. It improves modularity and maintainability. It breaks down large projects into simpler modules so that we can test these modules individually. Also by having all of our functions as pure functions we don’t have to worry have side effects that can happen so we can debug the code more quickly. Same thing with OOP it helps with modularity. Because everything is
What is the significance of the Any type in Scala?
Any in Scala is the supertype of all types. Every class in scala inherits either directly or indirectly from this class.
What does it mean that functions are first class citizens in Scala?
First-class functions are functions that can be treated like any other value. You can pass them to functions as arguments, return them from functions, and save them in variables.
What is a REPL?
The scala REPL stands for Read, Evaluate, Print, and Loop. It is just a tool on the command line that lets you write interactive scala code.
What’s the difference between an expression and a statement?
An expression usually refers to a piece of code that can be evaluated to a value, and is composed of variables, operators, function calls, and literals. A statement refers to a piece of code that executes a specific instruction or tells the computer to complete a task.
What is a higher ordered function?
Higher order functions take other functions as parameters or return functions as a result. An example of this could be the filter function that takes a predicate as a parameter, with predicate being just a function or method that returns a boolean value.
Why might we want to write an application using pure functions instead of impure functions?
One of the main advantages of writing pure functions vs impure functions are that they are easier to test and debug. Output only solely depends on input and nothing outside the scope of the function. There are no side effects or hidden input outputs to worry about.