Master the basics of Scala with these 30 multiple-choice questions covering its introduction, installation, first program, and REPL scripts. Perfect for beginners to test and solidify their understanding!
Getting Started with Scala
1. Introduction to Scala
Which programming paradigm does Scala support?
A) Object-oriented only
B) Functional only
C) Both object-oriented and functional
D) None
What is Scala primarily designed to run on?
A) .NET Framework
B) Java Virtual Machine (JVM)
C) Python Interpreter
D) Ruby Environment
Who developed Scala?
A) Guido van Rossum
B) Martin Odersky
C) James Gosling
D) Bjarne Stroustrup
In what year was Scala first released?
A) 1995
B) 2000
C) 2003
D) 2010
Scala’s name is derived from:
A) Its scalability
B) The Scala Valley
C) The initials of its creator
D) A Greek word
2. Installing Scala and IDE Setup
Which tool is typically used to build and manage Scala projects?
A) Maven
B) Gradle
C) sbt
D) npm
To install Scala on your system, you need:
A) A Python interpreter
B) The Java Development Kit (JDK)
C) A .NET runtime environment
D) Ruby Gems
Which IDE is most commonly used for Scala development?
A) IntelliJ IDEA
B) Eclipse
C) Visual Studio
D) NetBeans
What plugin is required to configure Scala in IntelliJ IDEA?
A) ScalaFX
B) Scala Plugin
C) Akka Plugin
D) sbt Plugin
What is the default file extension for Scala source files?
A) .scala
B) .java
C) .sc
D) .scalaSource
3. First Scala Program
Which keyword is used to define an object in Scala?
A) class
B) def
C) val
D) object
What is the entry point for a Scala application?
A) main() function inside a class
B) init() function inside an object
C) main() function inside an object
D) start() function inside a trait
How do you print a message to the console in Scala?
A) System.out.println()
B) print()
C) println()
D) Console.write()
Which is a valid way to define a method in Scala?
A) def methodName() = { /* code */ }
B) function methodName() { /* code */ }
C) var methodName() = { /* code */ }
D) fun methodName() { /* code */ }
What is the output of println("Scala".toUpperCase)?
A) Scala
B) SCALA
C) scala
D) SCala
4. REPL and Scripts
What does REPL stand for in Scala?
A) Read-Eval-Print-Loop
B) Runtime Execution Program Language
C) Run-Every-Program-Locally
D) Reflect-Evaluate-Program-List
How do you start the Scala REPL?
A) Type scala in the terminal
B) Run sbt run
C) Double-click Scala.jar
D) Use scala repl
What symbol is used to define a Scala script?
A) #
B) //
C) >
D) None (scripts are plain text files)
How do you execute a Scala script?
A) Run scala <script_name>
B) Type run in REPL
C) Compile it using javac
D) Execute it using python
Which of the following is true about REPL?
A) It only works with compiled Scala code
B) It allows interactive coding in Scala
C) It requires a GUI to operate
D) It does not support object creation
What command exits the Scala REPL?
A) quit
B) exit
C)
D)
How do you list all available commands in the REPL?
A) list commands
B) help()
C)
D) show all
In REPL, what does the :paste mode do?
A) Allows pasting of multi-line code
B) Automatically formats pasted code
C) Executes pasted code immediately
D) Disables output printing
Which REPL command compiles and runs Scala code in an external file?
A)<filename>
B)<filename>
C)<filename>
D)<filename>
What is the default output type of REPL expressions?
A) String
B) Unit
C) The evaluated type of the expression
D) None
Can you use val and var in the REPL?
A) No, only val is allowed
B) Yes, both are allowed
C) No, only var is allowed
D) Neither is allowed
Which of the following statements about REPL sessions is true?
A) Variables defined in REPL cannot be reused
B) You cannot define functions in REPL
C) REPL supports incremental compilation
D) REPL doesn’t allow imports
What command resets the REPL session?
A)
B)
C)
D)
Can you execute Scala commands line by line in REPL?
A) Yes, using the REPL prompt
B) No, only scripts are supported
C) Yes, but requires compilation first
D) No, REPL doesn’t support commands
What happens if you define a variable in REPL with the same name twice?