MCQs on Introduction to Scala | Scala

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

  1. Which programming paradigm does Scala support?
    • A) Object-oriented only
    • B) Functional only
    • C) Both object-oriented and functional
    • D) None
  2. What is Scala primarily designed to run on?
    • A) .NET Framework
    • B) Java Virtual Machine (JVM)
    • C) Python Interpreter
    • D) Ruby Environment
  3. Who developed Scala?
    • A) Guido van Rossum
    • B) Martin Odersky
    • C) James Gosling
    • D) Bjarne Stroustrup
  4. In what year was Scala first released?
    • A) 1995
    • B) 2000
    • C) 2003
    • D) 2010
  5. 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

  1. Which tool is typically used to build and manage Scala projects?
    • A) Maven
    • B) Gradle
    • C) sbt
    • D) npm
  2. 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
  3. Which IDE is most commonly used for Scala development?
    • A) IntelliJ IDEA
    • B) Eclipse
    • C) Visual Studio
    • D) NetBeans
  4. What plugin is required to configure Scala in IntelliJ IDEA?
    • A) ScalaFX
    • B) Scala Plugin
    • C) Akka Plugin
    • D) sbt Plugin
  5. What is the default file extension for Scala source files?
    • A) .scala
    • B) .java
    • C) .sc
    • D) .scalaSource

3. First Scala Program

  1. Which keyword is used to define an object in Scala?
    • A) class
    • B) def
    • C) val
    • D) object
  2. 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
  3. How do you print a message to the console in Scala?
    • A) System.out.println()
    • B) print()
    • C) println()
    • D) Console.write()
  4. 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 */ }
  5. What is the output of println("Scala".toUpperCase)?
    • A) Scala
    • B) SCALA
    • C) scala
    • D) SCala

4. REPL and Scripts

  1. 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
  2. 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
  3. What symbol is used to define a Scala script?
    • A) #
    • B) //
    • C) >
    • D) None (scripts are plain text files)
  4. 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
  5. 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
  6. What command exits the Scala REPL?
    • A) quit
    • B) exit
    • C)
    • D)
  7. How do you list all available commands in the REPL?
    • A) list commands
    • B) help()
    • C)
    • D) show all
  8. 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
  9. Which REPL command compiles and runs Scala code in an external file?
    • A)<filename>
    • B)<filename>
    • C)<filename>
    • D)<filename>
  10. What is the default output type of REPL expressions?
    • A) String
    • B) Unit
    • C) The evaluated type of the expression
    • D) None
  11. 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
  12. 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
  13. What command resets the REPL session?
    • A)
    • B)
    • C)
    • D)
  14. 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
  15. What happens if you define a variable in REPL with the same name twice?
    • A) Throws an error
    • B) Overwrites the previous value
    • C) Ignores the second definition
    • D) Prompts for a new name

Answers

QnoAnswer
1C) Both object-oriented and functional
2B) Java Virtual Machine (JVM)
3B) Martin Odersky
4C) 2003
5A) Its scalability
6C) sbt
7B) The Java Development Kit (JDK)
8A) IntelliJ IDEA
9B) Scala Plugin
10A) .scala
11D) object
12C) main() function inside an object
13C) println()
14A) def methodName() = { /* code */ }
15B) SCALA
16A) Read-Eval-Print-Loop
17A) Type scala in the terminal
18D) None (scripts are plain text files)
19A) Run scala <script_name>
20B) It allows interactive coding in Scala
21D)
22C)
23A) Allows pasting of multi-line code
24B)<filename>
25C) The evaluated type of the expression
26B) Yes, both are allowed
27C) REPL supports incremental compilation
28A)
29A) Yes, using the REPL prompt
30B) Overwrites the previous value

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top