MCQs on Building and Managing Projects | Scala

Master project management and build automation in Scala, focusing on sbt (Scala Build Tool), dependency management, plugins, packaging, and publishing libraries. Essential for efficient Scala development and deployment.


Building and Managing Projects in Scala

1. Using sbt (Scala Build Tool)

  1. What does sbt stand for in Scala?
    • A) Simple Build Tool
    • B) Scala Build Tool
    • C) Scala Batch Tool
    • D) Structured Build Tool
  2. What is sbt primarily used for in Scala projects?
    • A) Managing dependencies
    • B) Running Scala code
    • C) Building and compiling projects
    • D) All of the above
  3. Which file is used to configure sbt for a Scala project?
    • A) build.sbt
    • B) sbt.config
    • C) project.sbt
    • D) settings.sbt
  4. How do you specify Scala version in an sbt project?
    • A) In build.sbt using scalaVersion
    • B) In settings.sbt using scalaVersion
    • C) Using command line arguments
    • D) Automatically detected by sbt
  5. What command is used to compile a Scala project in sbt?
    • A) compile
    • B) sbt compile
    • C) build
    • D) run compile
  6. Which of the following sbt commands runs the project?
    • A) run
    • B) execute
    • C) start
    • D) launch
  7. What feature of sbt allows for incremental compilation?
    • A) Parallel compilation
    • B) Caching
    • C) Dependency management
    • D) Hot reloading
  8. In sbt, what does scalacOptions configure?
    • A) Scala runtime options
    • B) Scala compiler options
    • C) Dependency configurations
    • D) Build tool settings
  9. Which of the following is an sbt command to test Scala code?
    • A) test
    • B) sbt test
    • C) runTest
    • D) testCompile
  10. What is the purpose of the sbt clean command?
    • A) To delete the target directory
    • B) To compile the project
    • C) To install dependencies
    • D) To reset project settings

2. Managing Dependencies and Plugins

  1. How are dependencies declared in sbt?
    • A) Using the dependencies block in build.sbt
    • B) Using import statements
    • C) Using libraryDependencies block in build.sbt
    • D) Via the sbt console
  2. Which of the following is used to specify a plugin in sbt?
    • A) addPlugin
    • B) plugins.sbt
    • C) pluginDependencies
    • D) plugins.add
  3. In sbt, which method adds an external library dependency?
    • A) libraryDependencies +=
    • B) addDependencies
    • C) dependencies.add
    • D) importDependencies
  4. How do you add a dependency to a specific sbt configuration?
    • A) Use in keyword
    • B) Specify the configuration in the build.sbt
    • C) Use dependencyScope
    • D) Both A and B
  5. What is the purpose of sbt plugins?
    • A) To extend sbt functionality
    • B) To add support for Scala testing
    • C) To automate dependency resolution
    • D) To manage build scripts
  6. Which sbt plugin helps manage dependency versions?
    • A) sbt-updates
    • B) sbt-dependency-check
    • C) sbt-plugins
    • D) sbt-version
  7. What does sbt’s resolvers setting do?
    • A) Defines repositories for fetching dependencies
    • B) Caches downloaded dependencies
    • C) Defines external plugins
    • D) Checks for dependency conflicts
  8. Which of the following is an sbt plugin to integrate ScalaTest?
    • A) sbt-scalatest
    • B) sbt-test
    • C) sbt-junit
    • D) sbt-maven
  9. How do you list all available sbt plugins?
    • A) plugins list
    • B) listPlugins
    • C) show plugins
    • D) plugins --list
  10. What is the dependencyOverrides setting used for in sbt?
    • A) To override specific versions of libraries
    • B) To ensure dependencies are downloaded
    • C) To specify external repositories
    • D) To avoid circular dependencies

3. Packaging and Publishing Libraries

  1. What is the sbt command for packaging a project into a .jar file?
    • A) package
    • B) jar
    • C) sbt package
    • D) build
  2. How do you publish a Scala library to a remote repository in sbt?
    • A) Using publish command
    • B) Using sbt publishTo
    • C) Using deploy
    • D) Using upload
  3. Which sbt setting is used to specify the target repository for publishing?
    • A) publishTo
    • B) targetRepo
    • C) repoPath
    • D) deployTo
  4. What is the default repository for publishing libraries in sbt?
    • A) Maven Central
    • B) Scala Bintray
    • C) SBT Plugin Repository
    • D) GitHub Packages
  5. Which sbt command builds a project and publishes it to a remote repository?
    • A) publishLocal
    • B) publish
    • C) deploy
    • D) sbt publish
  6. Which command is used to publish a Scala library locally in sbt?
    • A) publishLocal
    • B) deployLocal
    • C) localPublish
    • D) buildPublish
  7. What file typically contains version information for Scala libraries in sbt?
    • A) version.sbt
    • B) build.sbt
    • C) libraryVersion.sbt
    • D) settings.sbt
  8. What is the purpose of the sbt assembly plugin?
    • A) To package a project into a single .jar file
    • B) To optimize Scala compilation
    • C) To deploy the project
    • D) To bundle dependencies with the project
  9. Which sbt command is used to publish a package to a repository after building?
    • A) publishTo
    • B) publish
    • C) deploy
    • D) push
  10. In sbt, what does the artifactId setting define when publishing a library?
    • A) The package name
    • B) The version of the library
    • C) The dependency scope
    • D) The unique identifier for the artifact

Answer Key

QnoAnswer (Option with the text)
1B) Scala Build Tool
2D) All of the above
3A) build.sbt
4A) In build.sbt using scalaVersion
5B) sbt compile
6A) run
7B) Caching
8B) Scala compiler options
9B) sbt test
10A) To delete the target directory
11C) libraryDependencies block in build.sbt
12B) plugins.sbt
13A) libraryDependencies +=
14D) Both A and B
15A) To extend sbt functionality
16A) sbt-updates
17A) Defines repositories for fetching dependencies
18A) sbt-scalatest
19D) plugins --list
20A) To override specific versions of libraries
21A) package
22B) Using sbt publishTo
23A) publishTo
24A) Maven Central
25B) publish
26A) publishLocal
27B) build.sbt
28A) To package a project into a single .jar file
29B) publish
30D) The unique identifier for the artifact

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