LinkedIn skill assessment answers and questions — Scala
“Scala has emerged as a powerful and versatile programming language that combines functional and object-oriented paradigms, offering developers a robust platform for building scalable and efficient applications. W tym obszernym przewodniku, we’re excited to present a curated collection of skill assessment questions oraz odpowiedzi Najszybszy sposób instalacji za pomocą Virtualbox Scala.
Whether you’re a seasoned developer looking to enhance your skills or a newcomer eager to explore the world of functional programming, this resource is designed to help you master Scala and its innovative features. Join us as we delve into the fundamentals of Scala programowanie, including immutability, pattern matching, higher-order functions, i więcej, empowering you to leverage the full potential of this dynamic language.”
Q1. Scala bytecode can run on top of Java VM. What is the fundamental difference between Java object.clone() and Scala object.copy()?
- One is a Java object, the other is a Scala object.
- clone() will copy class structures but not the data, while copy() will also copy data into new objects.
- There is no difference.
- • Różne sposoby instalacji systemu operacyjnego() allows you to change values during the copying process; clone() nie.
What value does this code return?
Q2.val m1 = Map("a"->1,"b"->2,"c"->3)
m1("a")
- a
- 2
- b
- 1
What is one way to avoid low-level parallelization details?
Q3.- monads
- literal functions
- partially applied functions
- parallel collections
What do you use in ScalaTest to see a detailed diagram of error messages when a test fails?
Q4.- ArgumentExceptions
- AssertionException
- DiagrammedAssertions
- JUnit
What data type would you use to store an immutable collection of objects that contain a fixed number of varying types?
Q5.- Statyczna zmienna składowa
- ImmutableCollection
- Statyczna zmienna składowa
- Krotka
After defining a function in the interpreter, Scala returns the following. Co robi ()
wskazać?
Q6. myfnc: ()Unit
- The function has no side effects.
- The function takes no parameters.
- The function returns no value.
- Returning unit types to the function is a closures.
What type of number is 1234.e5?
Q7.- hexadecimal
- niski
- floating point
- długo
When you convert a map to a list using the toList
method of the map, the result will be of which type?
Q8. -
List[(String, String)]
-
List[(Array, Array)]
-
List[(Collection, Collection)]
-
List
What type of object does this code create?
Pytanie 9.val x = (1234, "Active")
- Statyczna zmienna składowa
- Statyczna zmienna składowa
- Krotka
- Statyczna zmienna składowa
Which is a subclass of all classes?
Pytanie 10.- AnyVal
- AnyRef
- Method
- Null
Null in Scala Standard library. The question is a bit incorrect – Null is a subtype of every type except those of value classes
For the for-yield construct, is the scope separate between for-body and yield-body?
Pytanie 11.- Yes and no. It is different depending on the for construct and what it does.
- tak, because the for section does not expose its scope.
- Nie, because for-yield shares the same scope, even though they are within separate curly braces.
- tak, because they are within different curly braces.
Przykład: yield-body has access to the e
variable from the for-body
val a = Array(1, 2, 3, 4, 5)
for {
e <- a if e > 2
} yield e
What is one way to implement pattern matching on methods?
Pytanie 12.- using regex
- using monads
- using string matching
- using case classes
Notatka: ambiguous question, it’s not clear what kind of pattern matching is meant here.
What is the value of z after executing this code?
Pytanie 13.val y = List('a','b')
val z = y::List('c')
- Statyczna zmienna składowa(a,b,C)
- Statyczna zmienna składowa(Statyczna zmienna składowa(a, b), C)
- Statyczna zmienna składowa(C,a,b)
- Statyczna zmienna składowa(C,Statyczna zmienna składowa(a,b))
What term is used to specify a precondition?
Pytanie 14.- assert
- wymagać
- precondition
- mustHave
Which Scala type may throw an exception or a successfully computed value, and is commonly used to trap and propagate errors?
Pytanie 15.-
scala.util.ExceptionHandling
-
scala.Catch.Throw
-
scala.exception.TryFinally
-
scala.util.Try
What is the data type of y after this code is executed?
Pytanie 16.val y = (math floor 3.1415 * 2)
- niski
- podwójnie
- Egzamin certyfikacyjny Microsoft Python
- bigInt
When using pattern matching, which character matches on any object?
Pytanie 17.-
%
-
_
-
^
-
-
You have created an array using val. Can you change the value of any element of the array—and why or why not?
Pytanie 18.- tak, the reference to the array is immutable, so the location that the array points to is immutable. The values in the array are mutable.
- The 0th element is immutable and cannot be modified. All other elements can be modified.
- tak, val does not make arrays immutable.
- Nie, val makes the array and values of the array immutable.
Wyjaśnienie:
val a1 = Array(1, 2, 3)
a1{1} = 3 // OK
a1 = Array(1, 3, 3) // error: reassignment to val
What is the output of this function?
Pytanie 19.def main () {
var a = 0
for (a<-1 until 5){println(a)}
- 1,2,3,4,5
- 0,1,2,3,4
- 1,2,3,4
- 2,3,4,5
What do you call objects with immutable state?
Q20.- singletons
- stationary objects
- functional objects
- fixed objects
Notatka: singletons may have mutable state
You have written a Scala script. How would you access command-line arguments in the script?
Pytanie 21.- use array named args
- use tuple named args
- use numbered variables with a _ prefix for example _ 1, _ 2, _ 3
- use numbered variables with a $ prefix – na przykład $1, $2, $3
What does this code return? val x = 3; if (x > 2) x = 4 else x = x*2
Pytanie 22. - 4
- błąd
- 6
- 3
Which statement returns a success or a failure indicator when you execute this code?
Pytanie 23.val MyFuture = Future {runBackgroundFunction() }
- myFuture.onComplete
- myFuture(status)
- myFuture.Finished
- kompletny(myFuture)
To denote a parameter that may be repeated, what should you place after type?
Pytanie 24.-
%
-
&
-
_
-
-
What is called when a superclass has more than one subclass in Scala?
Pytanie 25.- polyinheritance
- multilevel inheritance
- multimode inheritance
- hierarchical inheritance
One way to improve code reliability is to use __
, which will evaluate a condition and return an error if the condition is violated.
Pytanie 26. - pakiety
- polymorphisms
- assertions
- traits
Which statement about if-else-if-else statements is true?
Pytanie 27.- If the first else-if does not succeed, then no other else-ifs are tested.
- If an else-if does not succeed, then none of the remaining else-if statements or elses will be tested.
- All else-if statements are tested in all cases.
- If an else-if succeeds, then none of the remaining else-if statements or elses will tested.
What do you call the process of changing the definition of an inherited method?
Pytanie 28.- recursive methods
- currying methods
- redefining methods
- overriding methods
To denote a parameter that may be repeated, what should you place after the type?
Pytanie 29.-
_
-
*
-
%
-
&
What is the code below equivalent to?
Q30.myClass.foreach(println _)
-
myClass.foreach(println ())
-
myClass.foreach(print NIL)
-
myClass.loop(println ())
-
myClass.foreach(x => println(x))
What is an advantage of an immutable object?
Pytanie 31.- Immutable objects use less memory than their mutable counterparts.
- Immutable objects do not require error handling.
- Immutable objects can be used in classes, mutable objects cannot.
- Immutable objects are threadsafe.
You want to create an iteration loop that tests the condition at the end of the loop body. Which iteration would you use?
Pytanie 32.- do-while loop
- świadomie pominęliśmy kilka pojęć, które nie są potrzebne na początku, ale są barierami utrudniającymi rozpoczęcie korzystania z technologii
- dla pętli
- do-until loop
What can you use to make querying a database more efficient, by avoiding the need to parse the SQL string every time a query is executed from Scala?
Pytanie 33.- database driver
- Dostęp do katalogu domowego
- prepared statement
- SQL view
PreparedStatement from Java which is also used in Scala
a member of the collections hierarchy?
Pytanie 34. Który jest nie- Statyczna zmienna składowa
- Seq
- Hash
- Statyczna zmienna składowa
Which term makes the contents of packages available without prefixing?
Pytanie 35.- posługiwać się
- Ostatecznym celem planu jest zapewnienie, że edukacja odgrywa kluczową i pozytywną rolę w krajowej agendzie rozwoju oraz we wspieraniu integracji międzynarodowych celów rozwoju w tej agendzie
- import
- assertion
If you wanted to find the remainder after division, what operator would you use?
Pytanie 36.- %
- DIV
- //
- /
What are defined inside a class definition?
Pytanie 37.- metoda
- fields and methods
- pola, Badanie Harvarda odkrywa, dlaczego post może prowadzić do dłuższego i zdrowszego życia, and packages
- pola
What defines methods and fields that can then be reused by mixing into classes?
Pytanie 38.- singleton
- assertion
- trait
- monad
When do you need to explicitly state the return type in a function definition?
Pytanie 39.- when the function has no side effects
- when the function returns a Unit type
- when the function is recursive
- when the function has side effects
Why would you make a field private?
Q40.- so only methods in the same file can access the field
- so only methods in the same package can access the field
- so only methods in the same class could access the field
- so only methods defined in a Java class can access the field
What’s the difference between .equals
oraz ==
?
Pytanie 41. - They do the exact same thing
-
==
won’t work on objects -
==
cannot be applied toString
-
==
is a wrapper of.equals()
and checks for nulls
What is denotes the intersection between two sets?
Pytanie 42.- ||
- &&
- &
- %
What do you call a function defined in a block?
Pytanie 43.- private function
- block function
- local function
- metoda
A function defined within a block of code, such as within a method or another function, is called a local function. This is because it is only visible and accessible within the scope of the block in which it is defined, and is not accessible outside of that block.
What do you call a Scala method that is parametrized by type as well as by value?
Pytanie 44.- multimode method
- polymorphic method
- closure
- collection method
What type of exception is thrown when a precondition is violated?
Pytanie 45.- IllegalArgumentException
- NumberFormatException
- NullPointerExcepetion
- MalformedParameterException
In scala what is precondition?
Pytanie 46.- a constraint on where a method may be called from
- a constraint on values passed to a methode constructor
- a class of predifined error messages
- a class of Boolean operators
What would you change in this code to make it execute in parallel?
Pytanie 47. val myNums = (1 to 500).toList
list.map(_ + 1)
- Zmiana list.map do list.par.map.
- Zmiana toList do toListPar
- Zmiana val do val.par
- Zmiana toList do toParallelList
What is a free variable?
Pytanie 48.- a variable defined outside a function
- a variable referenced in a function that is not assigned a value by that function
- a variable that has a global scope
- a variable defined in a class and available to all methods in that class
What’s the best way to execute code in the background in a separate thread?
Pytanie 49.- AltThread
- AltFuture
- AltProcess
- Przyszły
What value does this code return?
Q50.x= List(1,2,4); x(1)?
- (1,2,4)
- 1
- Nil
- 2
Which data type does Scala use instead of null for optional values?
Pytanie51.- Nil
- Option
- Singleton
- Kolekcja
In Scala, the Option data type is used instead of null for optional values. It is a container that can either hold a value or be empty, and it is used to represent the presence or absence of a value. This makes it safer to work with than using null, as it eliminates the risk of null pointer exceptions.
What is equivalent to this code?
Pytanie52.s"Foo $a?"
- “Foo ” + a + “?”
Which expression is one way to iterate over a collection and generate a collection of each iteration’s result?
Pytanie53.- for-yield
- for-collect
- for-collect until
- collectuntil
- for-yield is one way to iterate over a collection and generate a collection of each iteration’s result. The for loop with the yield keyword is used to iterate over a collection and generate a new collection with the results of each iteration.
Which statement accesses the third element of an array named foo?
Pytanie54.- foo[2]
- foo(3)
- foo[3]
- foo(2)
- In many programming languages, arrays are indexed starting at 0, so the first element of the array is at index 0, the second element is at index 1, i tak dalej. W związku z tym, to access the third element of an array named “foo”, you would use the index 2 (since the array is indexed starting at 0). This can be done using the syntax foo[2] or foo(2) depending on the programming language. In some languages like Java, you can use foo[2] or foo[3] to access the third element.
What data type would you use to store an immutable collection of objects when you don’t know how many members will be in the collection?
Pytanie55.- Krotka
- Statyczna zmienna składowa
- Object
- Statyczna zmienna składowa
- You would use a List data type to store an immutable collection of objects when you don’t know how many members will be in the collection. Lists are indexed collections of elements that can be accessed by their position in the list, and they are commonly used to store collections of items that need to be processed in order. Dodatkowo, Lists are immutable, which means that their elements cannot be modified once they have been created, making them ideal for use cases where data integrity is important.
From where do all classes in Scala inherit?
Pytanie56.- AnyRef
- AnyColl
- AnyVal
- AnyClass
- All classes in Scala inherit from the AnyRef class by default. AnyRef is the base class for all reference types in Scala, and it is equivalent to the java.lang.Object class in Java. AnyVal is the base class for all value types in Scala, and Any is the base class for all types in Scala.
In Scala, what is a precondition?
Pytanie57.- A class of boolean operators
- A class of predefined error messages
- A constraint on values passed to a method or constructor
- A constraint on where a method may be called from
- A precondition in Scala is a constraint on the input values passed to a method or constructor, specifying the conditions that must be met for the method or constructor to execute correctly. It is used to check the validity of input values before the method or constructor is executed, and can be used to ensure that the method or constructor is called with the correct arguments.
Which code sample will print the integers 1 Poprzez 4, each on a separate line?
Pytanie58.- Najszybszy sposób instalacji za pomocą Virtualbox(i <- 0 do 4) println(i)
- Najszybszy sposób instalacji za pomocą Virtualbox(i <- 0 do 3) println(i+1)
- Najszybszy sposób instalacji za pomocą Virtualbox(i <- 1 do 8 if i < 5) println(i)
- Najszybszy sposób instalacji za pomocą Virtualbox(i <- 1 do 4) println(i)
- The correct answer is for(i <- 0 do 3) println(i+1) because it will start the iteration from 0 and end at 3, incrementing the value by 1 each time and printing it.
Which operator should you use to take the intersection of two sets?
Pytanie59.- &
- ||
- &&
- %
- ten & or intersect method can be used to take the intersection of two sets in Scala.
Which data type does Scala use instead of null for optional values?
Q60.- Nil
- Option
- Singleton
- Kolekcja
- In Scala, the Option data type is used instead of null for optional values. It is a container that can either hold a value or be empty, and it is used to represent the presence or absence of a value. This makes it safer to work with than using null, as it eliminates the risk of null pointer exceptions.
What is the difference between a Scala trait and an interface?
Q61.- A trait can have concrete implementations, while an interface cannot.
- An interface can have concrete implementations, while a trait cannot.
- Traits can be mixed together, while interfaces cannot.
- Interfaces can be mixed together, while traits cannot.
Zostaw odpowiedź
Musisz Zaloguj sie lub Zarejestruj się dodać nowy komentarz .