अभी पंजीकरण करें

लॉग इन करें

पासवर्ड खो गया

आपका पासवर्ड खो गया है? कृपया अपना पूरा ईमेल दर्ज करें. आपको एक लिंक प्राप्त होगा और आप ईमेल के माध्यम से एक नया पासवर्ड बनाएंगे.

पोस्ट जोड़ें

पोस्ट जोड़ने के लिए आपको लॉगिन करना होगा .

प्रश्न जोड़ें

प्रश्न पूछने के लिए आपको लॉगिन करना होगा.

लॉग इन करें

अभी पंजीकरण करें

स्कॉलरसार्क.कॉम में आपका स्वागत है! आपका पंजीकरण आपको इस प्लेटफॉर्म की अधिक सुविधाओं का उपयोग करने की अनुमति देगा. आप सवाल पूछ सकते हैं, योगदान दें या उत्तर दें, अन्य उपयोगकर्ताओं के प्रोफ़ाइल देखें और बहुत कुछ. अभी पंजीकरण करें!

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. इस व्यापक मार्गदर्शिका में, we’re excited to present a curated collection of skill assessment questions तथा जवाब के लिये 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 प्रोग्रामिंग, including immutability, pattern matching, higher-order functions, और अधिक, 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.
  • • ओएस इंस्टाल करने के विभिन्न तरीके() allows you to change values during the copying process; clone() नहीं करता.

Q2. What value does this code return?

val m1 = Map("a"->1,"b"->2,"c"->3)
m1("a")
  • 2
  • बी
  • 1

Q3. What is one way to avoid low-level parallelization details?

  • monads
  • literal functions
  • partially applied functions
  • parallel collections

Q4. What do you use in ScalaTest to see a detailed diagram of error messages when a test fails?

  • ArgumentExceptions
  • AssertionException
  • DiagrammedAssertions
  • JUnit

Q5. What data type would you use to store an immutable collection of objects that contain a fixed number of varying types?

  • सरणी
  • ImmutableCollection
  • List
  • Tuple

Q6. After defining a function in the interpreter, Scala returns the following. क्या करता है () संकेत देना?

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.

क्यू 7. What type of number is 1234.e5?

  • पहला असेंबली भाषा प्रोग्राम लिखें और इसे एमुलेटर पर चलाएं
  • short
  • floating point
  • लंबा

क्यू 8. When you convert a map to a list using the toList method of the map, the result will be of which type?

  • List[(String, String)]
  • List[(Array, Array)]
  • List[(Collection, Collection)]
  • List

प्रश्न 9. What type of object does this code create?

val x = (1234, "Active")
  • List
  • नक्शा
  • Tuple
  • सरणी

प्र10. Which is a subclass of all classes?

  • AnyVal
  • AnyRef
  • Method
  • Null

Null in Scala Standard library. The question is a bit incorrectNull is a subtype of every type except those of value classes

प्रश्न 11. For the for-yield construct, is the scope separate between for-body and yield-body?

  • Yes and no. It is different depending on the for construct and what it does.
  • हां, because the for section does not expose its scope.
  • नहीं, because for-yield shares the same scope, even though they are within separate curly braces.
  • हां, because they are within different curly braces.

उदाहरण: 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

प्र12. What is one way to implement pattern matching on methods?

  • using regex
  • using monads
  • using string matching
  • using case classes

ध्यान दें: ambiguous question, it’s not clear what kind of pattern matching is meant here.

प्रश्न 13. What is the value of z after executing this code?

val y = List('a','b')
val z = y::List('c')
  • List(ए,बी,कीबोर्ड संशोधक चाबियों का एक समूह है जिसका उपयोग अन्य कुंजियों के व्यवहार को बदलने के लिए किया जा सकता है)
  • List(List(ए, बी), कीबोर्ड संशोधक चाबियों का एक समूह है जिसका उपयोग अन्य कुंजियों के व्यवहार को बदलने के लिए किया जा सकता है)
  • List(कीबोर्ड संशोधक चाबियों का एक समूह है जिसका उपयोग अन्य कुंजियों के व्यवहार को बदलने के लिए किया जा सकता है,ए,बी)
  • List(कीबोर्ड संशोधक चाबियों का एक समूह है जिसका उपयोग अन्य कुंजियों के व्यवहार को बदलने के लिए किया जा सकता है,List(ए,बी))

प्र14. What term is used to specify a precondition?

  • assert
  • ज़रूरत होना
  • precondition
  • mustHave

प्रश्न 15. Which Scala type may throw an exception or a successfully computed value, and is commonly used to trap and propagate errors?

  • scala.util.ExceptionHandling
  • scala.Catch.Throw
  • scala.exception.TryFinally
  • scala.util.Try

scala.util.Try

प्र16. What is the data type of y after this code is executed?

val y = (math floor 3.1415 * 2)
  • short
  • दोहरा
  • int
  • bigInt

प्रश्न 17. When using pattern matching, which character matches on any object?

  • %
  • _
  • ^
  • -

Pattern Matching

प्रश्न 18. You have created an array using val. Can you change the value of any element of the array—and why or why not?

  • हां, 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.
  • हां, val does not make arrays immutable.
  • नहीं, val makes the array and values of the array immutable.

Explanation:

val a1 = Array(1, 2, 3)
a1{1} = 3 // OK
a1 = Array(1, 3, 3) // error: reassignment to val

क्यू19. What is the output of this function?

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

प्र20. What do you call objects with immutable state?

  • singletons
  • stationary objects
  • functional objects
  • fixed objects

ध्यान दें: singletons may have mutable state

प्र21. You have written a Scala script. How would you access command-line arguments in the script?

  • 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 – उदाहरण के लिए $1, $2, $3

प्र22. What does this code return? val x = 3; if (x > 2) x = 4 else x = x*2

  • 4
  • an error
  • 6
  • 3

प्र23. Which statement returns a success or a failure indicator when you execute this code?

val MyFuture = Future {runBackgroundFunction() }

  • myFuture.onComplete
  • myFuture(status)
  • myFuture.Finished
  • पूरा(myFuture)

प्र24. To denote a parameter that may be repeated, what should you place after type?

  • %
  • &
  • _
  • -

प्रश्न25. What is called when a superclass has more than one subclass in Scala?

  • polyinheritance
  • multilevel inheritance
  • multimode inheritance
  • hierarchical inheritance

प्र26. One way to improve code reliability is to use __ , which will evaluate a condition and return an error if the condition is violated.

  • संकुल
  • polymorphisms
  • assertions
  • traits

प्र27. Which statement about if-else-if-else statements is true?

  • 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.

प्रश्न 28. What do you call the process of changing the definition of an inherited method?

  • recursive methods
  • currying methods
  • redefining methods
  • overriding methods

प्र29. To denote a parameter that may be repeated, what should you place after the type?

  • _
  • *
  • %
  • &

Repeated Parameters in Scala

क्यू30. What is the code below equivalent to?

myClass.foreach(println _)
  • myClass.foreach(println ())
  • myClass.foreach(print NIL)
  • myClass.loop(println ())
  • myClass.foreach(x => println(x))

प्रश्न31. What is an advantage of an immutable object?

  • 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.

प्र32. You want to create an iteration loop that tests the condition at the end of the loop body. Which iteration would you use?

  • do-while loop
  • घुमाव के दौरान
  • for loop
  • do-until loop

प्रश्न 33. 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?

  • database driver
  • कनेक्शन
  • prepared statement
  • SQL view

PreparedStatement from Java which is also used in Scala

प्रश्न34. Which is नहीं a member of the collections hierarchy?

  • तय करना
  • Seq
  • Hash
  • नक्शा

क्यू35. Which term makes the contents of packages available without prefixing?

  • उपयोग
  • शामिल
  • import
  • assertion

प्र36. If you wanted to find the remainder after division, what operator would you use?

  • %
  • DIV
  • //
  • /

प्रश्न37. What are defined inside a class definition?

  • तरीका
  • fields and methods
  • परीक्षण प्रबंधन के लिए, हार्वर्ड अध्ययन से पता चलता है कि क्यों उपवास एक लंबा और स्वस्थ जीवन जी सकता है, and packages
  • परीक्षण प्रबंधन के लिए

प्रश्न 38. What defines methods and fields that can then be reused by mixing into classes?

  • singleton
  • assertion
  • trait
  • monad

प्र39. When do you need to explicitly state the return type in a function definition?

  • 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

क्यू40. Why would you make a field private?

  • 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

प्र41. What’s the difference between .equals तथा ==?

  • They do the exact same thing
  • == won’t work on objects
  • == cannot be applied to String
  • == is a wrapper of .equals() and checks for nulls

स्रोत:

प्र42. What is denotes the intersection between two sets?

  • ||
  • &&
  • &
  • %

स्रोत:

प्रश्न 43. What do you call a function defined in a block?

  • private function
  • block function
  • local function
  • तरीका

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.

प्रश्न 44. What do you call a Scala method that is parametrized by type as well as by value?

  • multimode method
  • polymorphic method
  • closure
  • collection method

क्यू45. What type of exception is thrown when a precondition is violated?

  • IllegalArgumentException
  • NumberFormatException
  • NullPointerExcepetion
  • MalformedParameterException

प्र46. In scala what is precondition?

  • 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

प्रश्न 47. What would you change in this code to make it execute in parallel?

 val myNums = (1 to 500).toList
 list.map(_ + 1)
  • बदलना list.map प्रति list.par.map.
  • बदलना toList प्रति toListPar
  • बदलना val प्रति val.par
  • बदलना toList प्रति toParallelList

प्रश्न 48. What is a free variable?

  • 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

प्र49. What’s the best way to execute code in the background in a separate thread?

  • AltThread
  • AltFuture
  • AltProcess
  • भविष्य

क्यू50. What value does this code return?

x= List(1,2,4); x(1)?
  • (1,2,4)
  • 1
  • Nil
  • 2

प्रश्न51. Which data type does Scala use instead of null for optional values?

  • Nil
  • Option
  • Singleton
  • मित्सुबिशी जीएक्स वर्क्स

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.

प्रश्न52. What is equivalent to this code?

s"Foo $a?"
  • Foo ” + ए + “?”

प्रश्न53. Which expression is one way to iterate over a collection and generate a collection of each iteration’s result?

  • 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.

प्रश्न54. Which statement accesses the third element of an array named foo?

  • 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, और इसी तरह. इसलिए, to access the third element of an array namedfoo”, 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.

प्रश्न55. 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?

  • Tuple
  • List
  • Object
  • सरणी
  • 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. इसके साथ ही, 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.

प्रश्न56. From where do all classes in Scala inherit?

  • 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.

प्रश्न57. In Scala, what is a precondition?

  • 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.

प्र 58. Which code sample will print the integers 1 के माध्यम से 4, each on a separate line?

  • के लिये(मैं <- 0 प्रति 4) println(मैं)
  • के लिये(मैं <- 0 प्रति 3) println(i+1)
  • के लिये(मैं <- 1 प्रति 8 if i < 5) println(मैं)
  • के लिये(मैं <- 1 प्रति 4) println(मैं)
  • The correct answer is for(मैं <- 0 प्रति 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.

प्रश्न59. Which operator should you use to take the intersection of two sets?

  • &
  • ||
  • &&
  • %
  • NS & or intersect method can be used to take the intersection of two sets in Scala.

क्यू 60. Which data type does Scala use instead of null for optional values?

  • Nil
  • Option
  • Singleton
  • मित्सुबिशी जीएक्स वर्क्स
  • 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.

प्रश्न 61. What is the difference between a Scala trait and an interface?

  • 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.

संदर्भ

के बारे में हेलेन बस्सी

नमस्ते, I'm Helena, एक ब्लॉग लेखक जिसे शिक्षा क्षेत्र में ज्ञानवर्धक सामग्री पोस्ट करने का शौक है. मेरा मानना ​​है कि शिक्षा व्यक्तिगत और सामाजिक विकास की कुंजी है, और मैं अपने ज्ञान और अनुभव को सभी उम्र और पृष्ठभूमि के शिक्षार्थियों के साथ साझा करना चाहता हूं. मेरे ब्लॉग पर, आपको सीखने की रणनीतियों जैसे विषयों पर लेख मिलेंगे, ऑनलाइन शिक्षा, व्यवसायिक नीति, और अधिक. मैं अपने पाठकों की प्रतिक्रिया और सुझावों का भी स्वागत करता हूं, इसलिए बेझिझक एक टिप्पणी छोड़ें या किसी भी समय मुझसे संपर्क करें. मुझे आशा है कि आपको मेरा ब्लॉग पढ़ने में आनंद आएगा और यह उपयोगी और प्रेरणादायक लगेगा.

उत्तर छोड़ दें