scala面试问题

Before reading this post, please go through my previous two posts at “Scala Basic” and “Scala Intermediate” Interview Questions and Answers to get some basic knowledge about Scala Language.

在阅读本文之前,请仔细阅读我之前的两篇文章《 Scala Basic 》和《 Scala Intermediate 》面试问答,以获取有关Scala语言的一些基础知识。

Scala高级面试问题 (Scala Advanced Interview Questions)

In this post, we are going discuss about some Advanced Scala Interview Questions that are related to Scala Advanced concepts and also some Real-time project related concepts.

在本文中,我们将讨论一些与Scala Advanced概念相关的Advanced Scala面试问题以及一些与实时项目相关的概念。

Note: As this list has already become very large, I’m going to deliver another post with remaining Questions and Answers. Please refer that post at: “Scala Intermediate and Advanced Interview Questions and Answers”

注意:由于此列表已经非常庞大,因此我将提供另一篇文章,其中包含剩余的“问题与解答”。 请在以下位置参阅该帖子:“ Scala中级和高级面试问答 ”

We will also discuss Scala/Java Concurrency and Parallelism Interview Questions and Answers, which are useful for Senior or Experienced Scala/Java Developer.

我们还将讨论Scala / Java并发性和并行性面试问题和答案,这对资深或有经验的Scala / Java开发人员很有用。

Scala高级面试问题 (Scala Advanced Interview Questions)

In this section, we are going to list out all Scala Intermediate Interview Questions and in next section we will discuss them in detail.

在本节中,我们将列出所有Scala中级面试问题,在下一节中,我们将详细讨论它们。

  1. What is the current latest version of Scala?What is the major change or update in Scala 2.12?Scala的最新最新版本是什么?Scala 2.12的主要更改或更新是什么?
  2. What is Option in Scala? What are Some and None? What is Option/Some/None Design Pattern in Scala?Scala中的Option是什么? 什么是“无”? Scala中的选项/某些/无设计模式是什么?
  3. What is Either in Scala? What are Left and Right in Scala? Explain Either/Left/Right Design Pattern in Scala?在Scala中是什么? Scala中的左右是什么? 解释Scala中的任一/左/右设计模式?
  4. What is the equivalent construct of Scala’s Option in Java SE 8? What is the use of Option in Scala?Java SE 8中Scala选项的等效构造是什么? Scala中Option的用途是什么?
  5. What are the Advantages of Functional Programming (FP) or Advantages of Pure Functions?函数式编程(FP)的优点或纯函数的优点是什么?
  6. What are the Popular Scala-Based Frameworks to develop RESTful Web Services or REST API?有哪些流行的基于Scala的框架来开发RESTful Web服务或REST API?
  7. What is the best Framework to generate REST API documentation for Scala-based applications?为基于Scala的应用程序生成REST API文档的最佳框架是什么?
  8. Like Hibernate for Java-based applications, What are the Popular ORM Frameworks available to use in Play/Scala based applications?与基于Java的应用程序的Hibernate一样,可以在基于Play / Scala的应用程序中使用哪些流行的ORM框架?
  9. What is the best tool to develop Play/Scala applications to persist data in MongoDB NoSQL data store?开发Play / Scala应用程序以将数据持久存储在MongoDB NoSQL数据存储中的最佳工具是什么?
  10. Popular clients who are using Play and Scala to develop their applications?使用Play和Scala开发应用程序的受欢迎客户?
  11. What is the best language to use with Play framework: Scala or Java?与Play框架搭配使用的最佳语言是什么:Scala或Java?
  12. How Scala supports both Highly Scalable and Highly Performance applications?Scala如何支持高度可扩展和高性能应用程序?
  13. What are the available Build Tools to develop Play and Scala based Applications?有哪些可用的构建工具来开发基于Play和Scala的应用程序?
  14. What is SBT? What is the best Build Tool to develop Play and Scala Applications?什么是SBT? 什么是开发Play和Scala应用程序的最佳构建工具?
  15. What are the available Unit Testing, Functional Testing and/or BDD Frameworks for Play and Scala Based applications?对于基于Play和Scala的应用程序,有哪些可用的单元测试,功能测试和/或BDD框架?
  16. What is the best Code-coverage tool available for Play and Scala based applications?可用于基于Play和Scala的应用程序的最佳代码覆盖率工具是什么?
  17. What is the best Scala style checker tool available for Play and Scala based applications?可用于基于Play和Scala的应用程序的最佳Scala样式检查器工具是什么?
  18. Which IDEs support Play and Scala-Based Applications Development and how?哪些IDE支持基于Play和Scala的应用程序开发,以及如何支持?
  19. What is the default Unit and Functional Testing Framework for Play? What is the default Build Tool for Play? What is the Default Template Engine for Play? What is the built-in Web Server available in Play Framework?Play的默认单元和功能测试框架是什么? 默认的Play构建工具是什么? 什么是播放的默认模板引擎? Play Framework中可用的内置Web服务器是什么?
  20. Why Scala is better than Java? What are the advantages of Scala over Java (Java 8)? Compare to Java What are the major advantages or benefits of Scala?为什么Scala比Java更好? Scala与Java(Java 8)相比有什么优势? 与Java相比Scala的主要优点或优点是什么?
  21. What is an Anonymous Function In Scala? What is a Function Literal in Scala? What are the advantages of a Anonymous Function/Function Literal in Scala?Scala中的匿名函数是什么? Scala中的函数文字是什么? Scala中的匿名函数/函数文字有什么优势?
  22. What is an Higher-Order Function (HOF)?什么是高阶函数(HOF)?
  23. What are the differences between Case class and Normal Class?案例班和普通班有什么区别?
  24. What are the advantages of Play/Scala stack to develop web applications?Play / Scala堆栈开发Web应用程序有哪些优势?
  25. What is call-by-name? Does Scala and Java support call-by-name? What is the difference between call-by-value and call-by-name function parameters?什么是名字叫? Scala和Java是否支持按名称调用? 按值调用和按名称调用函数参数有什么区别?
  26. What are the Java’s OOP constructs not supported by Scala? What are the Scala’s OOP constructs not supported by Java? What are the new OOPs constructs introduced by Scala, but not supported by Java?Scala不支持哪些Java的OOP构造? Java不支持Scala的OOP构造是什么? Scala引入了什么新的OOPs构造,但是Java不支持这些构造?
  27. What are the popular MVC frameworks for Scala Language to develop Web Applications?Scala语言开发Web应用程序时流行的MVC框架是什么?
  28. What are major differences between Java-Based and Scala-Based Maven Project’s structure?基于Java和基于Scala的Maven项目的结构之间有哪些主要区别?
  29. What is Extractor in Scala? What is the difference between Constructor and Extractor in Scala? What is the use of Extractor in Scala?什么是Scala中的Extractor? Scala中的Constructor和Extractor有什么区别? Scala中Extractor的用途是什么?
  30. What is the use of ‘???’ in Scala-based Applications?'???'有什么用? 在基于Scala的应用程序中?
  31. Explain the main difference between List and Stream in Scala Collection API? How do we prove that difference? When do we choose Stream?解释Scala Collection API中List和Stream之间的主要区别? 我们如何证明这种差异? 我们什么时候选择Stream?
  32. What is the difference between :: and #:: in Scala? What is the difference between ::: and #::: in Scala?在Scala中::#::有什么区别? 在Scala中:::#:::有什么区别?
  33. If I want to become a Fullstack Scala Developer, which technology stack I should learn?如果我想成为Fullstack Scala开发人员,应该学习哪个技术堆栈?

Scala高级面试问答 (Scala Advanced Interview Questions and Answers)

In this section, we will pickup each and every question from above list and discuss in-detail with suitable examples(if required). If you want to understand these concepts in-depth with examples, please go through my previous posts in Scala Tutorials section.

在本节中,我们将从上面的列表中提取每个问题,并详细讨论适当的示例(如果需要)。 如果您想通过示例深入了解这些概念,请阅读我之前在Scala教程部分中的文章。

Scala的当前最新版本是什么? Scala 2.12中的主要更改或更新是什么? (What is the current latest version of Scala? What is the major change or update in Scala 2.12?)

Current Scala’s stable is 2.11.7. It supports Java SE 7.

当前Scala的稳定值为2.11.7。 它支持Java SE 7。

The major change or update in Scala 2.12 version is that it supports Java SE 8 or later versions only. Scala 2.12 is not a binary compatible with the 2.11.x series. It’s still in Mile Stone Builds only.

Scala 2.12版本中的主要更改或更新是它仅支持Java SE 8或更高版本。 Scala 2.12不是与2.11.x系列兼容的二进制文件。 它仍然仅在Mile Stone Builds中。

Scala中的Option是什么? 什么是“无”? Scala中的选项/某些/无设计模式是什么? (What is Option in Scala? What are Some and None? What is Option/Some/None Design Pattern in Scala?)

In Scala, Option is used to represent optional values that is either exist or not exist.
Option is an abstract class. Option has two subclasses: Some and None. All three (Option, Some and None) are defined in “scala” package like “scala.Option”.

在Scala中,Option用于表示存在或不存在的可选值。
Option是一个抽象类。 Option有两个子类:Some和None。 这三个选项(Option,Some和None)都在“ scala”包中定义,例如“ scala.Option”。

Option is a bounded collection in Scala, which contains either zero or one element. If Option contains zero elements that is None. If Option contains one element, that is Some.

Option是Scala中的有界集合,其中包含零或一个元素。 如果Option包含零个元素,则为None。 如果Option包含一个元素,则为Some。

Some is used to represent existing value. None is used to represent non-existent value.
Example:-

有些用于表示现有价值。 无用于表示不存在的值。
例:-

def get(val index: Int): Option[String]

Let us assume that this method is from List. This method has a return type of Option[String]. If List contains elements, this get method returns “Some[String]” element available in that index position. Otherwise, it returns “None” (that is no elements)

让我们假设此方法来自List。 此方法的返回类型为Option [String]。 如果List包含元素,则此get方法将返回在该索引位置可用的“ Some [String]”元素。 否则,它返回“无”(即没有元素)

Some is a case class and None is an Object. As both are case class/object, we can use them in Pattern Matching very well.

一些是案例类,无是对象。 由于两者都是案例类/对象,因此我们可以很好地在模式匹配中使用它们。

The combination of all these three definitions is known as Option/Some/None Design Pattern in Scala.

这三个定义的组合在Scala中称为“选项/某些/无设计模式”。

在Scala中是什么? Scala中的左右是什么? 解释Scala中的任一/左/右设计模式? (What is Either in Scala? What are Left and Right in Scala? Explain Either/Left/Right Design Pattern in Scala?)

In Scala, Either is an abstract class. It is used to represent one value of two possible types. It takes two type parameters: Either[A,B].

在Scala中,Either是一个抽象类。 它用于表示两种可能类型的一个值。 它带有两个类型参数:Either [A,B]。

It exactly have two subtypes: Left and Right. If Either[A,B] represents an instance A that means it is Left. If it represents an instance B that means it is Right.

它恰好具有两个子类型:左和右。 如果Either [A,B]表示实例A,则表示它为Left。 如果它表示实例B,则表示它是对的。

This is known as Either/Left/Right Design Pattern in Scala.

这在Scala中被称为“任一/左/右设计模式”。

Java SE 8中Scala选项的等效构造是什么? Scala中Option的用途是什么? (What is the equivalent construct of Scala’s Option in Java SE 8? What is the use of Option in Scala?)

Scala’s Option is similar to Java SE 8’s Optional. Java SE 8 has introduced a new utility class Optional to represent existing or non-existing of some value. Optional is available in java.util package.

Scala的Option与Java SE 8的Optional类似。 Java SE 8引入了一个新的可选实用程序类Optional,以表示某些值的存在或不存在。 可选在java.util包中可用。

Both Scala’s Option and Java SE 8’s Optional are used to represent optional values. Both are used to avoid unwanted null checks and NullPointerException.

Scala的Option和Java SE 8的Optional都用来表示可选值。 两者都用于避免不必要的null检查和NullPointerException。

函数式编程(FP)的优点或纯函数的优点是什么? (What are the Advantages of Functional Programming (FP) or Advantages of Pure Functions?)

The following are the Advantages of Functional Programming (FP) or Advantages of Pure Functions:

以下是函数编程(FP)的优点或纯函数的优点:

  • More Modular更多模块化
  • Easier to understand Or Easier reason about更容易理解或更容易理解
  • Easier to test更容易测试
  • Less prone to bugs不易出现错误
  • Easier to reuse易于重用
  • Easier to Parallelism and generalize易于并行化和泛化

有哪些流行的基于Scala的框架来开发RESTful Web服务或REST API? (What are the Popular Scala-Based Frameworks to develop RESTful Web Services or REST API?)

There are many Scala-Based Framework to develop RESTful Web Services. Most popular frameworks are:

有许多基于Scala的框架可用于开发RESTful Web服务。 最受欢迎的框架是:

  • Play Framework播放框架
  • In Play, we call REST API URLs as routes. We place all routes at once place in Play framework. It is a stateless web framework to develop REST API easily.

    在Play中,我们将REST API URL称为路由。 我们将所有路线一次放置在Play框架中。 这是一个易于开发REST API的无状态Web框架。

  • Scalatra FrameworkScalatra框架
  • It is very simple and easy Scala-based web framework to develop REST API

    这是一个非常简单,基于Scala的Web框架,用于开发REST API

  • Spray Framework喷涂框架
  • It is very concise and built on top of Akka framework so it’s better to develop REST API using Actor Model.

    它非常简洁,并基于Akka框架构建,因此最好使用Actor Model开发REST API。

  • Lift Framework升降机框架
  • It allows routing using Pattern Matching concept.

    它允许使用模式匹配概念进行路由。

为基于Scala的应用程序生成REST API文档的最佳框架是什么? (What is the best Framework to generate REST API documentation for Scala-based applications?)

Swagger is is the best tool for this purpose. It is very simple and open-source tool for generating REST APIs documentation with JSON for Scala-based applications.

Swagger是用于此目的的最佳工具。 这是一个非常简单且开源的工具,用于为基于Scala的应用程序使用JSON生成REST API文档。

  • If we use Play with Scala to develop your REST API, then use play-swagger module for REST API documentation.如果我们使用Play with Scala开发您的REST API,请使用play-swagger模块获取REST API文档。
  • If we use Spray with Scala to develop your REST API, then use spray-swagger module for REST API documentation.如果我们使用Spray with Scala开发您的REST API,请使用Spray-swagger模块获取REST API文档。

与基于Java的应用程序的Hibernate一样,可以在基于Play / Scala的应用程序中使用哪些流行的ORM框架? (Like Hibernate for Java-based applications, What are the Popular ORM Frameworks available to use in Play/Scala based applications?)

Like JPA, Hibernate and Toplink etc ORM Frameworks for Java-based applications, There are many ORM frameworks to use in Play/Scala based applications.
Popular ORM frameworks for Play/Scala based applications:

像JPA,Hibernate和Toplink等基于Java的应用程序的ORM框架一样,在基于Play / Scala的应用程序中可以使用许多ORM框架。
适用于基于Play / Scala的应用程序的流行ORM框架:

  • Slick光滑的
  • Anorm安诺姆
  • SORM(Scala ORM)SORM(Scala ORM)
  • SquerylSqueryl

开发Play / Scala应用程序以将数据持久存储在MongoDB NoSQL数据存储中的最佳工具是什么? (What is the best tool to develop Play/Scala applications to persist data in MongoDB NoSQL data store?)

ReactiveMongo is the best Scala Driver to develop Play/Scala applications to persist data in MongoDB NoSQL data store. It supports fully non-blocking and asynchronous I/O operations.

ReactiveMongo是开发Play / Scala应用程序以将数据持久存储在MongoDB NoSQL数据存储中的最佳Scala驱动程序。 它支持完全非阻塞和异步I / O操作。

使用Play和Scala开发应用程序的受欢迎客户? (Popular clients who are using Play and Scala to develop their applications?)

Thousands of clients are using Play and Scala in Production. The following list is the more popular clients who are using Play and Scala actively.

成千上万的客户正在生产中使用Play和Scala。 以下列表是积极使用Play和Scala的最受欢迎的客户。

  • LinkedIn领英
  • The Guardian守护者
  • Ocado奥卡多
  • LuchidChart卢希德·查特
  • GOV.UK英国政府

与Play框架搭配使用的最佳语言是什么:Scala或Java? (What is the best language to use with Play framework: Scala or Java?)

Play 2 is completely written in Scala. If we use Java with Play framework, we need to face many issues because Java does not support full FP features.

播放2完全用Scala编写。 如果我们将Java与Play框架一起使用,则需要面对许多问题,因为Java不支持完整的FP功能。

Scala is the best option to use with Play framework to develop Highly Scalable, Better Performance with Concurrency/Parallelism and Low latency applications, because:

Scala是与Play框架一起使用来开发具有并发性/并行性和低延迟应用程序的高度可扩展,更好性能的最佳选择,因为:

  • Play 2 is completely written in Scala.播放2完全用Scala编写。
  • It supports full FP features.它支持完整的FP功能。
  • It is more expression language than Java.它是比Java更多的表达语言。
  • It supports Akka Actor model very easily它很容易支持Akka Actor模型
  • It supports some new OOP feature like Traits.它支持一些新的OOP功能,例如特性。
  • Play’s built-in templates are developed in ScalaPlay的内置模板是在Scala中开发的

Scala如何支持高度可扩展和高性能应用程序? (How Scala supports both Highly Scalable and Highly Performance applications?)

As Scala supports Multi-Paradigm Programming(Both OOP and FP) and uses Actor Concurrency Model, we can develop very highly Scalable and high-performance applications very easily.

由于Scala支持Multi-Paradigm编程(OOP和FP),并使用Actor并发模型,因此我们可以非常轻松地开发具有高度可伸缩性和高性能的应用程序。

有哪些可用的构建工具来开发基于Play和Scala的应用程序? (What are the available Build Tools to develop Play and Scala based Applications?)

The following three are most popular available Build Tools to develop Play and Scala Applications:

以下是开发Play和Scala应用程序的最受欢迎的构建工具:

  • SBTSBT
  • MavenMaven
  • GradleGradle

什么是SBT? 什么是开发Play和Scala应用程序的最佳构建工具? (What is SBT? What is the best Build Tool to develop Play and Scala Applications?)

SBT stands for Scala Build Tool. Its a Simple Build Tool to develop Scala-based applications.

SBT代表Scala Build Tool。 它是一个简单的构建工具,用于开发基于Scala的应用程序。

Most of the people uses SBT Build tool for Play and Scala Applications. For example, IntelliJ IDEA Scala Plugin by default uses SBT as Build tool for this purpose.

大多数人都将SBT Build工具用于Play和Scala应用程序。 例如,默认情况下,IntelliJ IDEA Scala插件使用SBT作为构建工具。

对于基于Play和Scala的应用程序,有哪些可用的单元测试,功能测试和/或BDD框架? (What are the available Unit Testing, Functional Testing and/or BDD Frameworks for Play and Scala Based applications?)

The following are most popular available Unit Testing, Functional Testing and/or BDD Frameworks for Play/Scala Based applications:

以下是针对基于Play / Scala的应用程序中最受欢迎的单元测试,功能测试和/或BDD框架:

  • Spec2规格2
  • ScalaTestScalaTest
  • ScalaCheckScalaCheck
  • Mokito直人

可用于基于Play和Scala的应用程序的最佳代码覆盖率工具是什么? (What is the best Code-coverage tool available for Play and Scala based applications?)

SCoverage is the Code-coverage tool for Play and Scala based applications.

SCoverage是用于基于Play和Scala的应用程序的代码覆盖工具。

SCoverage stands for Scala Code-coverage tool. It has three separate plug-ins to supports the following build tools:

SCoverage代表Scala代码覆盖率工具。 它具有三个单独的插件来支持以下构建工具:

  • SBTSBT
  • MavenMaven
  • GradleGradle

可用于基于Play和Scala的应用程序的最佳Scala样式检查器工具是什么? (What is the best Scala style checker tool available for Play and Scala based applications?)

Like Checkstyle for Java-Based Applications, Scalastyle is best Scala style checker tool available for Play and Scala based applications.

与基于Java的应用程序的Checkstyle一样,Scalastyle是可用于基于Play和Scala的应用程序的最佳Scala样式检查器工具。

Scalastyle observes our Scala source code and indicates potential problems with it. It has three separate plug-ins to supports the following build tools:

Scalastyle会观察我们的Scala源代码并指出潜在的问题。 它具有三个单独的插件来支持以下构建工具:

  • SBTSBT
  • MavenMaven
  • GradleGradle

It has two separate plug-ins to supports the following two IDEs:

它具有两个单独的插件来支持以下两个IDE:

  • IntelliJ IDEAIntelliJ IDEA
  • Eclipse IDEEclipse IDE

哪些IDE支持基于Play和Scala的应用程序开发,以及如何支持? (Which IDEs support Play and Scala-Based Applications Development and how?)

The following two popular IDEs support Play and Scala-Based Applications Development:

以下两个流行的IDE支持Play和基于Scala的应用程序开发:

  • IntelliJ IDEAIntelliJ IDEA
  • Eclipse IDEEclipse IDE

They support by using Scala Plugins like Eclipse IDE has a Scala IDE for Eclipse to support Play and Scala-Based Applications Development.

它们通过使用Scala插件来支持,例如Eclipse IDE具有一个用于Eclipse的Scala IDE,以支持基于Play和Scala的应用程序开发。

IntelliJ IDEA has a plug-in like “Scala Plugin for IntelliJ IDEA” to support “Scala, SBT and Play 2 Framework” based applications.

IntelliJ IDEA具有类似于“ IntelliJ IDEA的Scala插件”的插件,可支持基于“ Scala,SBT和Play 2 Framework”的应用程序。

  • What is the default Unit and Functional Testing Framework for Play? What is the default Build Tool for Play? What is the Default Template Engine for Play? What is the built-in Web Server available in Play Framework?Play的默认单元和功能测试框架是什么? 默认的Play构建工具是什么? 什么是播放的默认模板引擎? Play Framework中可用的内置Web服务器是什么?
  • Play Framework’s default Unit and Functional Testing Framework is Spec2. It is very easy to test Play/Scala based applications using Spec2 Framework.

    Play框架的默认单位和功能测试框架为Spec2。 使用Spec2 Framework测试基于Play / Scala的应用程序非常容易。

    Play Framework’s Default built-in template is “Twirl”. It was developed in Scala. By using these templates, we can develop Play/Scala based applications very easily.

    Play Framework的默认内置模板为“旋转”。 它是在Scala中开发的。 通过使用这些模板,我们可以非常轻松地开发基于Play / Scala的应用程序。

    The Built-in or Default Web Server available for Play Framework is Netty Server.

    可用于Play框架的内置或默认Web服务器是Netty Server。

    为什么Scala比Java更好? Scala与Java(Java 8)相比有什么优势? 与Java相比Scala的主要优点或优点是什么? (Why Scala is better than Java? What are the advantages of Scala over Java (Java 8)? Compare to Java What are the major advantages or benefits of Scala?)

    Because Scala supports the following extra features, it is better than Java 8:

    由于Scala支持以下额外功能,因此它比Java 8更好:

    • Full FP Features完整的FP功能
    • More Expression Language更多表达语言
    • Pattern Matching模式匹配
    • Better support for Akka Actor Model更好地支持Akka Actor模型
    • Automatic resolution for Inheritance Diamond Problem with Traits具有特质的继承钻石问题的自动解决
    • Asynchronous and Non-blocking IO programming using Akka Framework使用Akka Framework进行异步和非阻塞IO编程
    • Fully Reactive Streaming API完全React式流API

    Scala中的匿名函数是什么? Scala中的函数文字是什么? Scala中的匿名函数/函数文字有什么优势? (What is an Anonymous Function In Scala? What is a Function Literal in Scala? What are the advantages of a Anonymous Function/Function Literal in Scala?)

    Anonymous Function is also a Function but it does not have any function name. It is also known as a Function Literal.
    The advantages of a Anonymous Function/Function Literal in Scala:

    匿名函数也是一个函数,但是它没有任何函数名称。 也称为功能文字。
    Scala中的匿名函数/函数文字的优点:

    • We can assign a Function Literal to variable我们可以将函数文字分配给变量
    • We can pass a Function Literal to another function/method我们可以将函数文字传递给另一个函数/方法
    • We can return a Function Literal as another function/method result/return value.我们可以将函数文字返回为另一个函数/方法结果/返回值。

    什么是高阶函数(HOF)? (What is an Higher-Order Function (HOF)?)

    Higher Order Function (HOF) is also a function but which performs one, two or both of the following things:

    高阶函数(HOF)也是一个函数,但是它执行以下一项或多项任务:

    • Take other functions as arguments以其他函数为参数
    • Return functions as their results返回函数作为结果

    案例班和普通班有什么区别? (What are the differences between Case class and Normal Class?)

    Case class is also a class, however when we compare it with normal class, it gives the following extra features or benefits:

    案例类也是一个类,但是当我们将其与普通类进行比较时,它具有以下额外的功能或好处:

    • By default, Case-class constructor parameters are ‘val’. We don’t need to declare parameters with ‘val’.默认情况下,Case-class构造函数参数为'val'。 我们不需要用'val'声明参数。
    • By default, Case-class constructor parameters become class fields.默认情况下,Case-class构造函数参数成为类字段。
    • These methods are added automatically: toString, equals, hashCode, copy. apply and unapply.这些方法会自动添加:toString,equals,hashCode,copy。 应用和不应用。
    • It automatically gets Companion object.它会自动获取Companion对象。
    • No need to use ‘new’ keyword to create instance of Case Class.无需使用“ new”关键字来创建Case类的实例。
    • Easy to use in Pattern Matching.易于在模式匹配中使用。

    All these features are added by Scala Compiler at compile-time. It is not possible with normal class.

    所有这些功能都是由Scala编译器在编译时添加的。 普通班不可能。

    Play / Scala堆栈开发Web应用程序有哪些优势? (What are the advantages of Play/Scala stack to develop web applications?)

    The following are the major advantages of Play/Scala stack to develop web applications:

    以下是Play / Scala堆栈开发Web应用程序的主要优点:

    • Open Source开源的
    • Play is an Open-source free-software framework to develop web applications.

      Play是用于开发Web应用程序的开放源代码免费软件框架。

    • Better Productivity更高的生产率
    • Play framework’s Auto-reload feature improves Developer Productivity. No need to build, deploy and test our changes. Just do our changes and refresh the page to see our changes.

      Play框架的自动重载功能提高了开发人员的生产力。 无需构建,部署和测试我们的更改。 只需进行更改,然后刷新页面即可查看更改。

    • Stateless and Easy to Develop REST API无状态且易于开发的REST API
    • Play is HTTP based stateless model to serve web requests so it is very easy to develop REST API or RESTful Web Services.

      Play是基于HTTP的无状态模型来服务Web请求,因此开发REST API或RESTful Web服务非常容易。

    • Better Error-Handling更好的错误处理
    • If we develop our web application using Play framework,it informs all errors in the browser in very useful format. It shows error message, the file location, line number where error occurred, highlighting the code-snippet to understand the error very easily.

      如果我们使用Play框架开发Web应用程序,它将以非常有用的格式通知浏览器中的所有错误。 它显示错误消息,文件位置,发生错误的行号,并突出显示代码片段以非常容易地理解错误。

    • High Performance and Better Scalability With Reactive具有React性的高性能和更好的可伸缩性
    • Play framework is developed by following Reactive design patterns and it is built on top of Netty sever to utilize Non-blocking IO Feature. Because of this feature, we can develop very highly Scalable and performance applications very easily.

      Play框架是根据Reactive设计模式开发的,它是基于Netty服务器构建的,以利用非阻塞IO功能。 由于此功能,我们可以非常轻松地开发高度可伸缩和高性能的应用程序。

    • Easy to Extend易于扩展
    • Play is very flexible framework and supports developing plug-ins very easy to extend it’s features and functionality.

      Play是一个非常灵活的框架,并支持非常容易地扩展其特性和功能的开发插件。

    • Highly Concurrency and Better Parallelism高度并发和更好的并行性
    • As both Scala and Play supports Functional Programming, it is very easy to develop Highly Concurrency and Better Parallelism applications very easily because FP supports Immutability, Pure Functions (Functions without side-effects), Pattern Matching, Actor Model etc.

      由于Scala和Play都支持函数式编程,因此很容易开发高度并发和更好的并行性应用程序,因为FP支持不变性,纯函数(无副作用的函数),模式匹配,Actor模型等。

    • Better Reusability, Easy to Test and More Modular更好的可重用性,易于测试和模块化
    • As both Scala and Play supports Functional Programming, we can develop more modular and reusable applications. It is also very easy to test more modular applications.

      由于Scala和Play都支持函数式编程,因此我们可以开发更多的模块化和可重用的应用程序。 测试更多模块化应用程序也非常容易。

    Scala不支持哪些Java的OOP构造? Java不支持Scala的OOP构造是什么? Scala引入了什么新的OOPs构造,但是Java不支持这些构造? (What are the Java’s OOP constructs not supported by Scala? What are the Scala’s OOP constructs not supported by Java? What are the new OOPs constructs introduced by Scala, but not supported by Java?)

    Java’s OOP constructs, which are not supported by Scala:

    Scala不支持Java的OOP构造:

    • There is no interface concept in ScalaScala中没有接口概念
    • There is no Enum concept in ScalaScala中没有Enum概念

    Scala’s OOP constructs, which are not supported by Java:
    OR
    The new OOPs constructs introduced by Scala, but not supported by Java:

    Scala的OOP构造,Java不支持:
    要么
    Scala引入了新的OOPs构造,但Java不支持:

    • Scala Traits斯卡拉特质
    • Solving Inheritance Diamond Problem automatically.自动解决继承钻石问题。

    什么是名字叫? Scala和Java是否支持按名称调用? 按值调用和按名称调用函数参数有什么区别? (What is call-by-name? Does Scala and Java support call-by-name? What is the difference between call-by-value and call-by-name function parameters?)

    Call-by-name means evaluates method/function parameters only when we need them or we access them. If we don’t use them, then it does not evaluate them.

    按名称调用意味着仅在需要它们或访问它们时才评估方法/函数参数。 如果我们不使用它们,那么它不会评估它们。

    Scala supports both call-by-value and call-by-name function parameters. However, Java supports only call-by-value, but not call-by-name.

    Scala支持按值调用和按名称调用功能参数。 但是,Java仅支持按值调用,不支持按名称调用。

    Difference between call-by-value and call-by-name:
    The major difference between these two are described below:

    按值致电和按姓名致电的区别:
    两者之间的主要区别如下所述:

    • In Call-by-name, the function parameters are evaluated only whenever they are needed but not when the function is called.在“按名称调用”中,仅在需要时才评估函数参数,而在调用函数时不评估它们。
    • In Call-by-value, the function parameters are evaluated when the function is called.在“按值调用”中,调用函数时会评估函数参数。
    • In Call-by-value, the parameters are evaluated before executing function and they are evaluated only once irrespective of how many times we used them in that function.在“按值调用”中,参数在执行函数之前先进行评估,并且无论我们在该函数中使用了多少次,它们都只会被评估一次。
    • In Call-by-name, the parameters are evaluated whenever we access them and they are evaluated each time we use them in that function.在“按名称呼叫”中,每当我们访问参数时都会对参数进行评估,并且每次在该函数中使用它们时都会对其进行评估。
    • Scala Syntax DifferencesScala语法差异
    • Call-by-value:

      按值致电:

    def myFunction(a: Int, b: Int) { }

    Here both a and b are Call-by-value parameters to myFunction.

    这里a和b都是myFunction的按值调用参数。

    Call-by-name:

    姓名呼叫:

    def myFunction(a: Int, b: => Int) { }

    Here both a is a Call-by-value parameter and b is Call-by-name to myFunction.

    这里,a都是按值调用参数,b是myFunction的按名称调用。

    Scala语言开发Web应用程序时流行的MVC框架是什么? (What are the popular MVC frameworks for Scala Language to develop Web Applications?)

    The following are the most popular MVC frameworks available for Scala Language to develop Web Applications:

    以下是可用于Scala语言开发Web应用程序的最受欢迎的MVC框架:

    • Play Framework播放框架
    • Scalatra FrameworkScalatra框架
    • Spray Framework喷涂框架
    • Lift Framework升降机框架

    基于Java和基于Scala的Maven项目的结构之间有哪些主要区别? (What are major differences between Java-Based and Scala-Based Maven Project’s structure?)

    Most of the Java-based projects uses Maven as their Build tool. However, most of the people uses SBT as build tool to develop their Scala-based applications, but Some Teams uses Maven too as a build tool to develop their Scala-based applications.

    大多数基于Java的项目都使用Maven作为其Build工具。 但是,大多数人都使用SBT作为构建工具来开发基于Scala的应用程序,但是某些团队也使用Maven作为构建工具来开发基于Scala的应用程序。

    Maven folder structure for both Java-based and Scala-based projects is almost same just one folder name change as shown in the below diagrams: java and scala folder names.

    基于Java的项目和基于Scala的项目的Maven文件夹结构几乎相同,只是更改了一个文件夹名称,如下图所示:Java和Scala文件夹名称。

    Java-based Maven Project Folder Structure:

    基于Java的Maven项目文件夹结构:

    Scala-based Maven Project Folder Structure:

    基于Scala的Maven项目文件夹结构:

    什么是Scala中的Extractor? Scala中的Constructor和Extractor有什么区别? Scala中Extractor的用途是什么? (What is Extractor in Scala? What is the difference between Constructor and Extractor in Scala? What is the use of Extractor in Scala?)

    Not only in Java and Scala, in almost all OOP languages Constructor is used to create (or assemble) an object or an instance of a Class using it’s parameters (or components). Extractor is quite opposite to Constructor.

    不仅在Java和Scala中,几乎在所有OOP语言中,构造函数都用于使用其参数(或组件)创建(或组装)对象或Class的实例。 提取器与构造器完全相反。

    In Scala, Extractor is used to decompose or disassemble an object into it’s parameters (or components).

    在Scala中,Extractor用于将对象分解或分解成其参数(或组件)。

    In Scala, apply method is a Constructor. Internally, Extractor uses unapply method to decompose an objects into it’s parts (or parameters). In Scala, Extractor is mainly used in Pattern Matching concept. We will discuss Pattern Matching concept soon.

    在Scala中,apply方法是一个构造方法。 在内部,Extractor使用unapply方法将对象分解为其部分(或参数)。 在Scala中,提取器主要用于模式匹配概念。 我们将很快讨论模式匹配的概念。

    '???'有什么用? 在基于Scala的应用程序中? (What is the use of ‘???’ in Scala-based Applications?)

    This ‘???’ three question marks is not an operator, a method in Scala. It is used to mark a method which is ‘In Progress’ that means Developer should provide implementation for that one.

    这个 '???' 三个问号不是运算符,是Scala中的一种方法。 它用于标记一种“进行中”的方法,这意味着开发人员应为该方法提供实现。

    This method is define in scala.PreDef class as shown below:

    此方法在scala.PreDef类中定义,如下所示:

    def ??? : Nothing = throw new NotImplementedError

    If we run that method without providing implementation, then it throws ‘NotImplementedError’ error as shown below:

    如果我们在不提供实现的情况下运行该方法,那么它将引发“ NotImplementedError”错误,如下所示:

    scala> def add(a:Int, b:Int) : Int = ???
    add: (a: Int, b: Int)Intscala> add(10,20)
    scala.NotImplementedError: an implementation is missing

    解释Scala Collection API中List和Stream之间的主要区别? 我们如何证明这种差异? 我们什么时候选择Stream? (Explain the main difference between List and Stream in Scala Collection API? How do we prove that difference? When do we choose Stream?)

    In Scala, both List and Stream are from Collection API and works almost similar. Both are Immutable collections.

    在Scala中,List和Stream均来自Collection API,并且工作原理几乎相似。 两者都是不可变的集合。

    However, there is one main difference between List and Stream in Scala Collection API: That is List elements are evaluated Eagerly and Stream elements are evaluated Lazily that means when we access them.

    但是,Scala Collection API中的List和Stream之间有一个主要区别:即,对List元素进行早期评估,对Stream元素进行延迟评估,这意味着我们对其进行访问。

    scala> var list1 = List(1,2,3,4)
    list1: List[Int] = List(1, 2, 3, 4)

    Here we can observe that all List elements evaluated at the time of creating List object. However, if we do same thing on Stream, we cannot see all elements. We can see only first evaluated element and remaining elements are evaluated lazily as shown below:

    在这里,我们可以看到在创建List对象时评估了所有List元素。 但是,如果我们在Stream上执行相同的操作,则看不到所有元素。 我们可以看到只有第一个求值的元素和剩余的元素被懒惰求值,如下所示:

    scala> var s1 = Stream(1,2,3,4)
    s1: scala.collection.immutable.Stream[Int] = Stream(1, ?)

    When we want Lazy collection to evaluate elements only when we access them then it’s better to use Stream.

    如果我们希望Lazy集合仅在访问元素时才评估元素,那么最好使用Stream。

    在Scala中::#::有什么区别? 在Scala中:::#:::有什么区别? (What is the difference between :: and #:: in Scala? What is the difference between ::: and #::: in Scala?)

    In Scala Collection API,

    在Scala Collection API中,

    • :: and ::: are methods available in List class.:::::是List类中可用的方法。
    • #:: and #::: are methods available in Stream class#::#:::是Stream类中可用的方法
    • In List class, :: method is used to append an element to the beginning of the list.在List类中, ::方法用于将元素追加到列表的开头。
    scala> var list1 = List(1,2,3,4)
    list1: List[Int] = List(1, 2, 3, 4)scala> list1 = 0 :: list1
    list1: List[Int] = List(0, 1, 2, 3, 4)
  • In List class, ::: method is used to concatenate the elements of a given list in front of this list.在List类中, :::方法用于将给定列表的元素连接到此列表的前面。
  • scala> var list1 = List(3,4,5)
    list1: List[Int] = List(3, 4, 5)scala> val list2 = List(1,2) ::: list1
    list2: List[Int] = List(1, 2, 0, 1, 2, 3, 4)
  • In Stream class, #:: method is used to append a given element at beginning of the stream. Only this newly added element is evaluated and followed by lazily evaluated stream elements.在Stream类中, #::方法用于在流的开头附加给定元素。 仅评估此新添加的元素,然后再进行延迟评估的流元素。
  • scala> var s1 = Stream(1,2,3,4)
    s1: scala.collection.immutable.Stream[Int] = Stream(1, ?)scala> s1 = 0 #:: s1
    s1: scala.collection.immutable.Stream[Int] = Stream(0, ?)
  • In Stream class, #::: method is used to concatenate a given stream at beginning of the stream. Only this newly added element is evaluated and followed by lazily evaluated stream elements.在Stream类中, #:::方法用于在流的开头连接给定的流。 仅评估此新添加的元素,然后再进行延迟评估的流元素。
  • scala> var s1 = Stream(1,2,3,4)
    s1: scala.collection.immutable.Stream[Int] = Stream(1, ?)scala> val s2 = Stream(-1,0) #::: s1
    s2: scala.collection.immutable.Stream[Int] = Stream(-1, ?)
  • :: method works as a cons operator for List class and #:: method words as a cons operator for Stream class. Here ‘cons’ stands for construct.::方法用作List类的cons运算符,而#::方法字用作Stream类的cons运算符。 这里的“缺点”代表构造。
  • ::: method works as a concatenation operator for List class and #::: method words as a concatenation operator for Stream class.:::方法用作List类的串联运算符,而#:::方法字用作Stream类的串联运算符。
  • 如果我想成为Fullstack Scala开发人员,应该学习哪个技术堆栈? (If I want to become a Fullstack Scala Developer, which technology stack I should learn?)

    If you want to become a Fullstack Scala Developer, you should learn the following technology stack:

    如果您想成为Fullstack Scala开发人员,则应该学习以下技术堆栈:

    • Scala 2.11.7斯卡拉2.11.7
    • Play 2.4.6 Framework播放2.4.6框架
    • Akka 2.3 FrameworkAkka 2.3框架
    • One Build Tool: SBT/Maven一个构建工具:SBT / Maven
    • One JS Framework: CoffeeScript/JavaScript一个JS框架:CoffeeScript / JavaScript
    • One IDE: IntelliJ IDEA 15/ Eclipse IDE 4.x一个IDE:IntelliJ IDEA 15 / Eclipse IDE 4.x
    • One TDD & BDD Framework: ScalaTest,Spec2,ScalaCheck,Mockito一个TDD和BDD框架:ScalaTest,Spec2,ScalaCheck,Mockito
    • Micro Services with Play and Scala具有Play和Scala的微服务
    • SCoverage覆盖范围
    • Scalastyle斯卡拉风格
    • Functional Programming Design Patterns功能编程设计模式
    • Machine Learning with Scala使用Scala进行机器学习

    NOTE:- In Scala, Extractor follows Extractor Design Pattern. If you want to learn it in depth, please go through my Scala Tutorial (Most of the posts follows this pattern: Scala xxxx In Depth where xxxx is a concept like Extractor).

    注意:-在Scala中,提取器遵循提取器设计模式。 如果您想深入学习它,请阅读我的Scala教程(大多数文章都遵循这种模式:Scala xxxx在深度中,xxxx是类似Extractor的概念)。

    That’s it all about “Scala Advanced Interview Questions and Answers”. We will discuss some more Scala Interview Questions and Answers in my coming posts.

    关于“ Scala高级面试问答”的全部内容。 在我的后续文章中,我们将讨论更多Scala面试问答。

    Please drop me a comment if you like my post or have any issues/suggestions.

    如果您喜欢我的帖子或有任何问题/建议,请给我评论。

    翻译自: https://www.journaldev.com/8960/scala-advanced-interview-questions

    scala面试问题

scala面试问题_Scala高级面试问答相关推荐

  1. scala面试问题_Scala面试问题

    scala面试问题 Before reading this post, please go through my previous post at "Scala Basic Intervie ...

  2. Java经典基础与高级面试36题和答案

    在Java面试的首轮,经常会问很多关于Java面试基础以及高级的问题,今天收集相关Java面试36题和答案分享出来. 1."static"关键字是什么意思?Java中是否可以覆盖( ...

  3. 我的Java自学之路,java高级面试笔试题

    我总结出了很多互联网公司的面试题及答案,并整理成了文档,以及各种学习的进阶学习资料,免费分享给大家. 扫描二维码或搜索下图红色VX号,加VX好友,拉你进[程序员面试学习交流群]免费领取.也欢迎各位一起 ...

  4. android 移除泛型中元素_最新(2020)Android高级面试知识点干货分享(二)

    最新Android高级面试知识点干货分享(一) *转载请说明出处*! 四.Java集合(List.Set.Queue.Map) Java集合体系是一个树状,如果按照类似OSI网络模型来看的话,整个Ja ...

  5. Android 高级面试-2:IPC 相关

    内容 IPC 就是指跨进程通信.IPC 相关的内容,涉及的主要有: 常见的 IPC 通信方式: Binder 相关: 两种序列化方式及其对比: 问题 IPC Android 上的 IPC 跨进程通信时 ...

  6. 安卓高级面试知识整理

                                                    安卓高级面试知识整理 Android 四大组件:这是一份全面 & 详细的Activity学习指南 ...

  7. boss直聘java几轮面试,京东商城java高级面试:通过在Boss直聘上收到来自京东金 - 职朋职业圈...

    为了帮助职业圈网友能够及时了解京东商城的面试流程以及面试过程所涉及的面试问题,职业圈小编把刚获得的京东商城面试经验马上编辑好,快速提供给大家,以便能够尽快帮助到有需要的人.这次面试总共花了1天.面试形 ...

  8. 真香!180页100+题15W+字解析的《Java高级面试指南》,果断收下

    近期有很多朋友在考虑跳槽,"面试造火箭,工作拧螺丝"这话说得十分吻合他们的现状!而说到准准备面试,那是真不容易,趁着空挡我也收集了不少Java高级面试资源! 而这180页100+题 ...

  9. 【笔记-面试】《imooc -前端跳槽面试技巧》、《imooc- 揭秘一线互联网企业 前端javaScript高级面试》、《imooc-前端javascript面试技巧》

    20190204:<imooc -前端跳槽面试技巧> 第01章 课程介绍 01-01 课程导学 一.一面知识点 1.面试技巧 页面布局类 2.css盒模型dom事件类 3.http协议类 ...

最新文章

  1. supervisor 守护php,laravel队列之Supervisor守护进程(centos篇)
  2. Smooth_L1_Loss函数的计算方式
  3. C#获取控制台句柄的方法
  4. 科大星云诗社动态20210502
  5. [ORGINAL]OOP Panel control design(based on web )
  6. java.lang.NoSuchFieldError: EMPTY_ORDERED_ITERATOR起因及解决办法
  7. Google发布文档数据库Firestore
  8. linux system更好方法,Linux将程序添加到服务的方法(通用【但最好还是用systemd】)...
  9. 【信息系统项目管理师】第1章-信息化和信息系统 知识点详细整理
  10. c#读写apk的 comment
  11. 《数据资产管理实践白皮书4.0》下载!(附PPT解读)
  12. 数据结构_C语言_实验三_图 ——六度空间
  13. iOS进阶 - GCD总结
  14. Cesium3Dtilesets 使用customShader的解读以及泛光效果示例
  15. Oracle导出DMP文件的两种方法
  16. 2+22+222+2222
  17. Mongodb 3.6安装过程(centos7.9)
  18. Oracle VM VirtualBox Ubuntu设置共享文件夹
  19. 子比主题最新6.8开心版
  20. 【渝粤题库】陕西师范大学500019 电路分析

热门文章

  1. SQL Cookbook:一、检索记录(2)从表中检索部分行
  2. phpmyadmin安全预防
  3. django部署到linux上不显示.svg图标处理方法
  4. 判断一个网站用什么服务器
  5. MySql表名的大小写问题
  6. iOS6中旋转的略微改变
  7. (转自dflying chen)使用Anthem.NET 1.5中的FileUpload控件实现Ajax方式的文件上传
  8. 数据结构上机实践第13周项目1 - 验证Prim算法的验证
  9. linux安装或卸载mysql5,Linux环境下卸载、安装及配置MySQL5.1
  10. socket java 客户端_Java基于socket实现的客户端和服务端通信功能完整实例