scala面试问题
Welcome to Scala interview questions and answers. Now-a-days, most of the Finance/Banking, Government, Telecom, Social Networking etc. companies are using Scala, Play and Akka Framework to develop their projects because these frameworks support both OOPs and FP features and also provide many advantages.
欢迎来到Scala面试问答。 如今,大多数金融/银行,政府,电信,社交网络等公司都在使用Scala,Play和Akka框架来开发其项目,因为这些框架既支持OOPs也支持FP功能,并且还具有许多优势。
我将通过几篇文章与您分享面试的知识和Scala生态系统或Fullstack Scala (Scala / Play / Akka)开发经验。
I’m going to share you 3 separate posts. Some questions are just one question and some have some sub-questions. Totally am going to discuss around 200 questions. I bet if you are familiarise with all these questions, you will definitely clear all Scala Developer interviews. However, if you want to continue as a Fullstack Scala developer, you should learn all these Fullstack Scala technologies thoroughly.
我将与您分享3个单独的帖子。 有些问题只是一个问题,有些有一些子问题。 总共将讨论200个问题。 我敢打赌,如果您熟悉所有这些问题,那么您一定会清除所有Scala Developer访谈。 但是,如果您想继续作为Fullstack Scala开发人员,则应该彻底学习所有这些Fullstack Scala技术。
I’m going to deliver Scala/Play/Akka Interview Questions and Answers in three parts:
我将分三个部分提供Scala / Play / Akka面试问题和答案:
We will discuss some basic Scala Interview questions here, which are useful for Freshers or Java Developers want to move to Scala development or 1+ Year of Experience as Scala Developer.
我们将在这里讨论一些基本的Scala面试问题,这些对于那些希望转入Scala开发或希望拥有超过1年的Scala开发人员经验的Java或Java开发人员很有用。
We will discuss some interview questions, which are useful for 2+ Years of Experience as Scala/Java Developer.
我们将讨论一些面试问题,这些问题对于作为Scala / Java开发人员2年以上的经验很有用。
We will discuss some Interview Questions, which are useful for Senior or Experienced Scala/Java Developer.
我们将讨论一些面试问题,这些问题对于资深或经验丰富的Scala / Java开发人员很有用。
We will discuss Scala/Java Concurrency and Parallelism Interview Questions and Answers, which are useful for Senior or Experienced Scala/Java Developer.
我们将讨论Scala / Java并发性和并行性面试问题和答案,这对资深或有经验的Scala / Java开发人员很有用。
We will also discuss about some difference between Scala and Java constructs so that Users (who are moving from Java to Scala) can get benefits from these posts.
我们还将讨论Scala与Java构造之间的一些区别,以便用户(从Java迁移到Scala)可以从这些文章中受益。
In this post, we are going discuss about some basic Scala Interview Questions. Read my coming posts for rest of the two sections.
在这篇文章中,我们将讨论一些基本的Scala面试问题。 阅读我即将发布的文章,了解这两部分的其余部分。
In this section, we are going to list out all Scala Basic Interview Questions and in next section we will discuss them in detail.
在本节中,我们将列出所有Scala基本面试问题,在下一节中,我们将详细讨论它们。
Please refer my previous post to learn more about Functional Programming (Click this link to open my previous post).
请参考我以前的文章,以了解有关函数式编程的更多信息(单击此链接以打开我的先前的文章)。
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 stands for SCAlable LAnguage. Martin Odersky is the father of Scala.
Scala代表SCA标签LA语言。 Martin Odersky是Scala的父亲。
Scala is a Multi-Paradigm Programming Language, which supports both Object-Oriented and Functional Programming concepts. It is designed and developed by Martin Odersky.
Scala是一种多天堂编程语言,它支持面向对象和功能编程概念。 它是由Martin Odersky设计和开发的。
Scala is a Type-Safe Object-Functional Programming JVM Language. Scala runs on JVM(Java Virtual Machine).
Scala是一种类型安全的对象函数编程JVM语言。 Scala在JVM(Java虚拟机)上运行。
Scala is a Hybrid Functional (Object-Oriented and Functional) Programming JVM Language. Scala has a Strong and Statically Type System. In Scala, all types are checked at compile-time.
Scala是一种混合功能(面向对象和功能)编程JVM语言。 Scala具有强大的静态类型系统。 在Scala中,所有类型都在编译时检查。
Yes, Scala is a Statically-Typed Language.
是的,Scala是一种静态类型的语言。
Statically-Typed Language means that Type checking is done at compile-time by compiler, not at run-time. The main Advantage of these kinds of Languages is: As a Developer, we should care about writing right code to avoid all compile-time errors. As Compiler checks many of the errors at compile-time, we don’t get much issues or bugs at run-time.
静态类型语言意味着类型检查是在编译时由编译器完成的,而不是在运行时完成的。 这些语言的主要优点是:作为开发人员,我们应该关心编写正确的代码,以避免所有编译时错误。 当编译器在编译时检查许多错误时,在运行时我们不会遇到太多问题或错误。
Examples:- Java, Scala, C, C++, Haskell etc.
范例 :-Java,Scala,C,C ++,Haskell等。
Dynamically-Typed Language means that Type checking is done at run-time, not at compile-time by compiler. As a compiler won’t check any type checking at compile-time, We can expect more run-time issues or bugs.
动态类型语言意味着类型检查在运行时完成,而不是在编译时由编译器完成。 由于编译器在编译时不会检查任何类型检查,因此我们可以期待更多的运行时问题或错误。
Example:- Groovy, JavaScript, Ruby, Python, Smalltalk etc.
示例 :-Groovy,JavaScript,Ruby,Python,Smalltalk等。
Pure Object-Oriented Programming Language means that everything should be an Object.
纯面向对象的编程语言意味着一切都应该是一个对象。
Java is not a Pure Object-Oriented Programming (OOP) Language because it supports the following two Non-OOP concepts:
Java不是纯面向对象编程(OOP)语言,因为它支持以下两个非OOP概念:
Yes, Scala is a Pure Object-Oriented Programming Language because in Scala, everything is an Object and everything is a value. Functions are values and values are Objects.
是的,Scala是一种纯面向对象的编程语言,因为在Scala中,一切都是对象,一切都是值。 函数是值,值是对象。
Scala does not have primitive data types and also does not have static members.
Scala没有原始数据类型,也没有静态成员。
Yes, Scala supports all Functional Programming (FP) concepts. Java 8 has introduced some Functional Programming constructs, but it does NOT support all Functional Programming concepts.
是的,Scala支持所有函数式编程(FP)概念。 Java 8引入了一些函数式编程结构,但是它不支持所有的函数式编程概念。
For instance, Java 8 does not support Pattern Matching, Function Currying, Implicits etc.
例如,Java 8不支持模式匹配,函数固化,隐式等。
If we use Scala Language to develop our applications, we can get the following benefits or advantages and drawbacks:
Advantages of Scala Language:-
如果使用Scala语言开发应用程序,则可以得到以下好处或优点和缺点:
Scala语言的优点:-
Drawbacks of Scala Language:-
Scala语言的缺点:
NOTE:- We can write Scala Code either more readable or less readable way.
注意:-我们可以以更易读或不易读的方式编写Scala代码。
Apart from many benefits of Scala, it has one major Drawback: Backward Compatibility Issue. If we want to upgrade to latest version of Scala, then we need to take care of changing some package names, class names, method or function names etc.
除了Scala的许多优点之外,它还有一个主要缺点:向后兼容性问题。 如果我们想升级到最新版本的Scala,则需要注意更改某些软件包名称,类名称,方法或函数名称等。
For instance, If you are using old Scala version and your project is using BeanProperty annotation. It was available in “scala.reflect” like “scala.reflect.BeanProperty” in old versions. If we want to upgrade to new Scala versions, then we need to change this package from “scala.reflect” to “scala.beans”.
例如,如果您正在使用旧的Scala版本,而您的项目正在使用BeanProperty批注。 与旧版本中的“ scala.reflect.BeanProperty”类似,它在“ scala.reflect”中可用。 如果要升级到新的Scala版本,则需要将此软件包从“ scala.reflect”更改为“ scala.beans”。
Like Java’s Motto “Write Once Run Anywhere”, Scala has “Do More With Less” or “Do More With Less Code” Motto.
“Do More With Less” means that we can develop more complex program or logic with less code.
就像Java的座右铭“编写一次在任何地方运行”一样,Scala的座右铭是“ 事半功倍”或“事半功倍” 。
“事半功倍”意味着我们可以用更少的代码开发更复杂的程序或逻辑。
Java, Scala, Groovy and Closure are most popular JVM (Java Virtual Machine) languages.
Java,Scala,Groovy和Closure是最流行的JVM(Java虚拟机)语言。
Scala, Groovy and Closure JVM languages supports both Object-Oriented Programming Features and Functional Programming Features.
Scala,Groovy和Closure JVM语言同时支持面向对象的编程功能和功能编程功能。
Java SE 8 supports all Object-Oriented Programming Features. However, it supports very few Functional Programming Features like Lambda Expressions, Functions, Type Inference, Higher-Order Functions.
Java SE 8支持所有面向对象的编程功能。 但是,它仅支持极少数的函数式编程功能,例如Lambda表达式,函数,类型推断,高阶函数。
As we know in Java, the super class of all classes (Java API Classes or User Defined Classes) is java.lang.Object. In the same way in Scala, the super class of all classes or traits is “Any” class.
众所周知,在Java中,所有类(Java API类或用户定义的类)的超类都是java.lang.Object。 在Scala中,所有类或特征的超类都是“ Any”类。
Any class is defined in scala package like “scala.Any”.
任何类都在scala包中定义,例如“ scala.Any”。
In Scala, if we don’t mention any access modifier to a method, function, trait, object or class, the default access modifier is “public”. Even for Fields also, “public” is the default access modifier.
在Scala中,如果我们没有对方法,函数,特征,对象或类提及任何访问修饰符,则默认访问修饰符为“ public”。 即使对于字段,“ public”也是默认的访问修饰符。
Because of this default feature, Scala does not have “public” keyword.
由于此默认功能,Scala没有“ public”关键字。
Types can be inferred by the Scala Compiler at compile-time. It is known as “Type Inference”. Types means Data type or Result type. We use Types at many places in Scala programs like Variable types, Object types, Method/Function Parameter types, Method/Function return types etc.
可以在编译时由Scala编译器推断类型。 它被称为“类型推断”。 类型是指数据类型或结果类型。 我们在Scala程序的许多地方使用类型,例如变量类型,对象类型,方法/函数参数类型,方法/函数返回类型等。
In simple words, determining the type of a variable or expression or object etc at compile-time by compiler is known as “Type Inference”.
简单来说,由编译器在编译时确定变量,表达式或对象等的类型称为“类型推断”。
Similarities between Scala’s Int and Java’s java.lang.Integer:
Scala的Int和Java的java.lang.Integer之间的相似之处:
Differences between Scala’s Int and Java’s java.lang.Integer:
Scala的Int与Java的java.lang.Integer之间的区别:
Java’s Integer is something similar to Scala’s Int and RichInt. RichInt is a final class defined in scala.runtime package like “scala.runtime.RichInt”.
Java的Integer与Scala的Int和RichInt类似。 RichInt是在scala.runtime包中定义的最终类,例如“ scala.runtime.RichInt”。
In Scala, the Relationship between Int and RichInt is that when we use Int in a Scala program, it will automatically convert into RichInt to utilize all methods available in that Class. We can say that RichInt is an Implicit class of Int. (We will discuss “What is Implicit and the advantages of Implicits in my next post).
在Scala中,Int和RichInt之间的关系是,当我们在Scala程序中使用Int时,它将自动转换为RichInt以利用该Class中可用的所有方法。 我们可以说RichInt是Int的隐式类。 (我们将在下一篇文章中讨论“什么是隐式的以及隐式的优点”)。
In Scala, Nothing is a Type (final class). It is defined at the bottom of the Scala Type System that means it is a subtype of anything in Scala. There are no instances of Nothing.
在Scala中,什么都不是类型(最终类)。 它在Scala类型系统的底部定义,这意味着它是Scala中任何内容的子类型。 没有Nothing的实例。
Use Cases of Nothing In Scala:-
If Nothing does not have any instances, then when do we use this one in Scala Applications?
Scala中没有内容的用例:-
如果Nothing没有任何实例,那么我们何时在Scala应用程序中使用该实例?
object None extends Option[Nothing]
Nil is an object, which is used to represent an empty list. It is defined in “scala.collection.immutable” package as shown below:
Nil是一个对象,用于表示一个空列表。 它在“ scala.collection.immutable”包中定义,如下所示:
object Nil extends List[Nothing]
Example:-
例:-
scala> Nil
res5: scala.collection.immutable.Nil.type = List()
scala> Nil.length
res6: Int = 0
Null is a Type (final class) in Scala. Null type is available in “scala” package as “scala.Null”. It has one and only one instance that is null.
Null是Scala中的Type(最终类)。 Null类型在“ scala”包中作为“ scala.Null”可用。 它只有一个实例为null。
In Scala, “null” is an instance of type scala.Null type.
在Scala中,“ null”是scala.Null类型的实例。
Example:-
例:-
scala> val myNullRef : Null = null
myNullRef: Null = null
We cannot assign other values to Null type references. It accepts only ‘null’ value.
我们不能将其他值分配给Null类型引用。 它仅接受“空”值。
Null is a subtype of all Reference types. Null is at the bottom of the Scala Type System. As it is NOT a subtype of Value types, we can assign “null” to any variable of Value type.
Null是所有引用类型的子类型。 Null在Scala类型系统的底部。 由于它不是值类型的子类型,因此我们可以将“空”分配给任何值类型的变量。
Example:-
例:-
scala> val myInt : Int = null
:10: error: an expression of type Null is ineligible for implicit conversion
val myInt : Int = null
^
^
Here type mismatch error. found : Null(null) but required: Int. The implicit conversions between Null and Int are not applicable because they are ambiguous.
在这里输入不匹配错误。 找到:Null(null),但必需:Int。 Null和Int之间的隐式转换不适用,因为它们是模棱两可的。
In Scala, Unit is used to represent “No value” or “No Useful value”. Unit is a final class defined in “scala” package that is “scala.Unit”.
在Scala中,单位用于表示“无值”或“无有用值”。 Unit是在“ scala”包中定义的最终类,即“ scala.Unit”。
Unit is something similar to Java’s void. But they have few differences.
单位类似于Java的void。 但是它们几乎没有区别。
Both are used to represent a method or function is not returning anything.
两者均用于表示方法或函数未返回任何内容。
In Scala, both val and var are used to define variables. However, they have some significant differences.
在Scala中,val和var均用于定义变量。 但是,它们之间存在一些显着差异。
REPL stands for Read-Evaluate-Print Loop. We can pronounce it as ‘ripple’. In Scala, REPL is acts as an Interpreter to execute Scala code from command prompt. That’s why REPL is also known as Scala CLI(Command Line Interface) or Scala command-line shell.
REPL代表读取-评估-打印循环。 我们可以将其发音为“涟漪”。 在Scala中,REPL充当从命令提示符执行Scala代码的解释器。 这就是为什么REPL也称为Scala CLI(命令行界面)或Scala命令行外壳的原因。
The main purpose of REPL is that to develop and test small snippets of Scala code for practice purpose. It is very useful for Scala Beginners to practice basic programs.
REPL的主要目的是为实践目的开发和测试Scala代码的小片段。 对于Scala初学者来说,练习基本程序非常有用。
We can access REPL by using “scala” command. When we type “scala” command at CMD Prompt, we will get REPL shell where we can type and execute scala code.
我们可以使用“ scala”命令访问REPL。 当在CMD Prompt键入“ scala”命令时,我们将获得REPL shell,可以在其中键入和执行scala代码。
D:\> scala
scala>
Scala Language supports the following features:
Scala语言支持以下功能:
We know how to implement loops in Object-Oriented style: Using Mutable Temporary variables, update the variable value and use Loop constructs. It is very tedious and unsafe approach. It is not Thread-Safe.
我们知道如何以面向对象的方式实现循环:使用Mutable Temporary变量,更新变量值并使用Loop构造。 这是非常繁琐和不安全的方法。 它不是线程安全的。
Object-Oriented style uses the following constructs to implement Loops:
面向对象的样式使用以下构造来实现循环:
We can implement same Loops differently in Functional way. It is Thread-Safe. We can use the following two techniques to implement the loops in functional style:
我们可以以功能方式不同地实现相同的循环。 这是线程安全的。 我们可以使用以下两种技术以功能样式实现循环:
Scala Application:
In Scala, App is a trait defined in scala package like “scala.App”. It defines main method. If an Object or a Class extends this trait, then they will become as Scala Executable programs automatically because they will inherit main method from Application.
Scala应用程序:
在Scala中,App是在scala包(例如“ scala.App”)中定义的特征。 它定义了主要方法。 如果对象或类扩展了此特性,则它们将自动成为Scala可执行程序,因为它们将从Application继承主方法。
The main advantage of using App is that we don’t need to write main method. The main drawback of using App is that we should use same name “args” to refer command line argument because scala.App’s main() method uses this name.
使用App的主要优点是我们不需要编写main方法。 使用App的主要缺点是我们应该使用相同的名称“ args”来引用命令行参数,因为scala.App的main()方法使用此名称。
Example:-
Without Scala App:
例:-
如果没有Scala应用:
object MyApp {
def main( args: Array[String]){
println("Hello World!")
}
}
With Scala App:
使用Scala应用程序:
object MyApp extends App{
println("Hello World!")
}
If we observe above two examples, in second example we have not defined main method because we have inherited from Scala App(Application).
如果我们观察以上两个示例,则在第二个示例中,由于我们已从Scala App(Application)继承而未定义main方法。
Before Scala 2.9, we have scala.Application trait. But it is deprecated by scala.App since Scala 2.9 version.
在Scala 2.9之前,我们具有scala.Application特性。 但是从Scala 2.9版本开始,scala.App弃用了它。
Java does not support Operator Overloading. Scala supports Operator Overloading.
Java不支持运算符重载。 Scala支持操作员重载。
The reason is that Java does not want to support some misleading method names like “+*/”. Scala has given this flexibility to Developer to decide which methods/functions name should use.
原因是Java不想支持某些令人误解的方法名称,例如“ + * /”。 Scala使开发人员可以灵活地决定应使用的方法/函数名称。
When we call 2 + 3 that means ‘+’ is not an operator, it is a method available in Int class (or it’s implicit type). Internally, this call is converted into “2.+(3)“.
当我们调用2 + 3时,意味着“ +”不是运算符,它是Int类(或其隐式类型)中可用的方法。 在内部,此调用转换为“ 2。+(3) ”。
Expression:
Expression is a value that means it will evaluate to a Value. As an Expression returns a value, We can assign it to a variable.
表达:
表达式是一个值,表示它将计算为一个值。 当表达式返回值时,我们可以将其分配给变量。
Example:- Scala’s If condition, Java’s Ternary operator.
示例:-Scala的If条件,Java的Ternary运算符。
Statement:
Statement defines one or more actions or operations. That means Statement performs actions. As it does not return a value, we cannot assign it to a Variable.
声明:
语句定义一个或多个动作或操作。 这意味着声明执行动作。 由于它不返回值,因此我们无法将其分配给变量。
Example:- Java’s If condition.
示例:-Java的If条件。
Java’s “If..Else”:
In Java, “If..Else” is a statement, not an expression. It does not return a value and cannot assign it to a variable.
Java的“ If..Else”:
在Java中,“ If..Else”是语句,而不是表达式。 它不返回值,也不能将其分配给变量。
Example:-
例:-
int year;
if( count == 0)
year = 2014;
else
year = 2015;
Scala’s “If..Else”:
In Scala, “If..Else” is an expression. It evaluates a value i.e. returns a value. We can assign it to a variable.
Scala的“ If..Else”:
在Scala中,“ If..Else”是一个表达式。 它评估一个值,即返回一个值。 我们可以将其分配给变量。
val year = if( count == 0) 2014 else 2015
NOTE:-Scala’s “If..Else” works like Java’s Ternary Operator. We can use Scala’s “If..Else” like Java’s “If..Else” statement as shown below:
注意: -Scala的“ If..Else”的工作方式类似于Java的三元运算符。 我们可以像Java的“ If..Else”语句一样使用Scala的“ If..Else”,如下所示:
val year = 0
if( count == 0)
year = 2014
else
year = 2015
In Scala, everything is a value. All Expressions or Statements evaluates to a Value. We can assign Expression, Function, Closure, Object etc. to a Variable. So Scala is an Expression-Oriented Language.
在Scala中,一切都是价值。 所有表达式或语句均求值。 我们可以将表达式,函数,闭包,对象等分配给变量。 因此Scala是一种面向表达的语言。
In Java, Statements are not Expressions or Values. We cannot assign them to a Variable. So Java is not an Expression-Oriented Language. It is a Statement-Based Language.
在Java中,语句不是表达式或值。 我们不能将它们分配给变量。 因此,Java不是面向表达式的语言。 它是一种基于语句的语言。
NOTE:-This list goes beyond one page. However, these are some important points to remember about differences in Scala and Java features to face Scala Interviews.
注意:-此列表超出一页。 但是,这些是要记住有关面对Scala采访的Scala和Java功能差异的一些重要要点。
Scala supports both functions and methods. We use same syntax to define functions and methods, there is no syntax difference.
Scala支持功能和方法。 我们使用相同的语法定义函数和方法,没有语法差异。
However, they have one minor difference:
但是,它们之间只有一个细微的差别:
NOTE:- We will discuss about Class, Trait,Package, Object etc in my coming posts.
注意:-我们将在我的后续文章中讨论有关类,特性,包装,对象等的信息。
In Java, we can define at-most one public class/interface in a Source file. Unlike Java, Scala supports multiple public classes in the same source file.
在Java中,我们可以在Source文件中定义至少一个公共类/接口。 与Java不同,Scala在同一源文件中支持多个公共类。
We can define any number of public classes/interfaces/traits in a Scala Source file.
我们可以在Scala源文件中定义任意数量的公共类/接口/特征。
We know, java.lang is the default package imported into all Java Programs by JVM automatically. We don’t need to import this package explicitly.
我们知道,java.lang是JVM自动导入所有Java程序的默认软件包。 我们不需要显式导入此程序包。
In the same way, the following are the default imports available in all Scala Programs:
同样,以下是所有Scala程序中可用的默认导入:
Unlike Java and like C++, Scala supports Operator Overloading. Scala has one and only operator that is “=” (equalto) operator. Other than this all are methods only.
与Java和C ++不同,Scala支持运算符重载。 Scala有一个唯一的运算符,即“ =”(等于)运算符。 除此之外,仅是方法。
For instance 2 + 3, here “+” is not an Operator in Scala. “+” is method available in Int class. Scala Compiler observes 2 and 3 are Integers and tries to find that “+” method in Int class. So Scala Compiler converts “2 + 3” expression into “2.+(3)” and make a call to “+” method on integer object “2” and pass integer object “3” as parameter to “+” method.
例如2 + 3,这里的“ +”不是Scala中的运算符。 “ +”是Int类中可用的方法。 Scala编译器观察到2和3是整数,并尝试在Int类中找到“ +”方法。 因此,Scala编译器将“ 2 + 3”表达式转换为“ 2。+(3)”,并在整数对象“ 2”上调用“ +”方法,并将整数对象“ 3”作为参数传递给“ +”方法。
Both “2 + 3” and “2.+(3)” are equal. It’s just Scala’s syntactic sugar to write programs in Functional style.
“ 2 + 3”和“ 2。+(3)”相等。 用功能风格编写程序只是Scala的语法工具。
Java uses the following keywords extensively:
Java广泛使用以下关键字:
Scala does not required these two keywords. Scala does not have ‘public’ and ‘static’ keywords.
Scala不需要这两个关键字。 Scala没有“ public”和“ static”关键字。
h3>What is PreDef in Scala? What is the main purpose of PreDef in Scala?
h3> Scala中的PreDef是什么? PreDef在Scala中的主要目的是什么?
In Scala, PreDef is an object defined in scala package as “scala.PreDef”. It is an utility object.
在Scala中,PreDef是在Scala包中定义为“ scala.PreDef”的对象。 它是一个实用程序对象。
It defines many utility methods as shown below:
它定义了许多实用程序方法,如下所示:
For instance, print, println, readLine, readInt, require etc methods are defined in PreDef object.
例如,在PreDef对象中定义了print,println,readLine,readInt,require等方法。
In Scala, PreDef is available to use its methods without importing in all Scala Programs because Scala Compiler imports this object into all compilation units like Class, Object, Trait etc. automatically.
在Scala中,PreDef可以使用其方法而无需在所有Scala程序中导入,因为Scala编译器会自动将此对象导入所有编译单元(如Class,Object,Trait等)中。
That’s it all about “Scala Basic Interview Questions and Answers”. We will discuss some Intermediate, Advanced and Real-time 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/8958/scala-interview-questions-answers
scala面试问题