1. When importing all the names of a package or class, which character do you use instead of " * "?
2. If you are defining scala classes in a 'package examplepackage', and want to ensure that a function 'foo' is only accessible by classes defined in the same package, how would you declare that function?
3. How would you get a List that was the result of appending `5:Int` to a `List(1,2,3)`. The order of the elements in the resulting List is irrelevant.
4. In the expression: List(1,2,3).foldLeft(x){case (a,b) => a+b} `x` is:
5. Describe class AnyRef
6. A valid description of a covariant type parameter would be:
7. Does Scala support tail-call recursion?
8. `Nil` is generally the same as:
9. What is the tool "schema2src" used for?
10. Classes in Scala, in contrast to Java, can have ______.
11. What is the defaut parameter call semantics?
12. Which statement about case classes is false?
13. In the expression: List(1,2,3) reduceLeft ( (a,b) => a+b ) `b` refers to:
14. Which statement best describes a partial function?
15. What is the result type of the following expression? List(1, 2, true, false)
16. It is possible to override methods inherited from a _____ in Scala.
17. Which statement is true about sealed classes.
18. Witch one of the following operators is use for sequencing Parsers
19. What is the largest Tuple that Scala supports?
20. Scala supports which types of polymorphism?
21. In Scala, type parameters and abstract types may be constrained by a _____.
22. The following code will > var x=100; var y=200; x->y
23. True or False? Scala compiler will never require you to specify the result type of a function.
24. Which of the following is a pattern matching any value, without giving it a name, represented by " _ "?
25. What is the value of the following expression? { val a = List(1,2,3) val b = List(4,5,6) (a,b).zipped.map(_+_) }
26. Explain how "abc".length returns 3
27. What is a higher-order function?
28. Which statement best describes an Iterator
29. True or False? Methods taking one argument can be used with infix syntax?
30. What is an expression following the "if" keyword?
31. What would be the result of: Option[String]("hi") match { case None=> "hello!" }
32. Scala is:
33. True or False? Multiple classes can be imported from the same package by enclosing them in curly braces {}.
34. Does Scala support the return keyword?
35. True or False? Like pre 1.5 Java, Scala suffers from lack of genericity.
36. When a class inherits from a trait, it inherits all the code contained in the trait and implements the trait's:
37. Scala's "Unit" roughly corresponds to which Java type?
38. Which of the following best describes Scala?
39. What is a class with a single instance?
40. Everything, including numbers and functions, are _______ in Scala.
41. What is the name of the Scala compiler?
42. When no super-class is specified, ______ is implicitly used.
43. True or False? Scala provides static members (members or fields).
44. Which statement about pattern matching is true?
45. How would you define the method: def +(a:Int):Int in a Java interface that will be overriden or used in Scala code?
46. Which statement about List is false?
47. True or False? In the Interpreter, you can define a new val with a name that was already used before.
48. What is the data type of myVariable in the following: val myVariable = if (true) "Hello"
49. Is it possible in Scala to declare a variable of type `Int` with a value of `null`?
50. What will the following function return: def foo(o:Any) = { o match { case Option(x) => "hi!" case anything => anything } } When passed a 'None' object?
51. `() => Unit` is best described as
52. What would be returned by the following function: def foo(l:List[Int]) = { var x=l.head; l.collect{ case a:Int if a>x => x=a; a }; x } When passed: List(2,4,6,8,6,3,1)
53. What is a lazy var?
54. Are parenthesis `(` and curly braces `{` interchangeable?
55. Which predicate tests whether x is object identical to y?
56. Which of these are NOT ways in which case classes differ from standard classes?
57. Which statement about the Option[+A] class is false?
58. Which of the following descriptions of case classes is *NOT* correct:
59. def g(): Int = try { 1 } finally { 2 } Calling g() results in
60. Which of the following is not one of the ways to increment the value of a variable i of type Int by 1.
61. "Option" is:
62. What is the Scala development environment designed for use in schools?
63. What is the runtime class of Unit?
64. A function which associates a value to a (variable) name is known as a(n):
65. def f(): Int = try { return 1 } finally { return 2 } Calling f() results in
66. True or False? Scala compiler automatically infers function parameter types.
67. Which statement is false about the functions in Scala?
68. Choose the correct statement which explains the error?
69. Which one about functional combinators is false?
70. Choose the best statement to describe this error?
71. How do you provide overloaded constructors in Scala?
72. Choose the correct description for both expressions?
73. Which statement is incorrect about Stream?
74. Which code statement is correct, Using scala object inside java?
75. Which one is true for Objects, Traits and Classes?
76. Choose expression that shows the correct output?
77. Choose correct statement which solves the error when you remove the line implicit
78. For the code below choose correct statement?
79. Which one is false for Scala?
80. Statement that best describe's the Scala 'apply' function?
81. Choose the expression that shows the correct output?
82. Read code and tell when do Scala functions execute?
83. Statement that is not correct for trait Traversable?
84. Choose the correct statement which solves the error?
85. String interpolation allows users to _____ variable references directly in processed string literals?
86. Best way to “clone” a case class?
87. Correct statement which describes the code?
88. Scala provides __ versions of all of its collection types. These versions cannot be changed after they are initialized. You should use them whenever you know a collection should not be changed, so that you do not accidentally change it later?
89. In which case there is only a small speed penalty?
90. If Seq is a trait then why is var x = Seq(1, 2, 3) legal?
91. Statement that is not correct for parallel collections?
92. Choose the correct statement which shows the output?
93. Statement that is not correct using the code below?
94. Choose output of the given code?
95. Choose output of given code below?
96. For the code below, Choose the correct statement that describes an issue with the code?
97. Output of following code?
98. How to groupBy using multiple columns in Scala collections?
99. Choose correct output using the code?
100. Statement that is not correct for Scala's mutable.Map?
101. The map method on List (and Seq), transforms each element of a collection based on a function. For example, if we have a List[String] and want to convert it to all lowercase?
102. What is the output?
103. Which one is not valid using List?
104. How can you make a List[String] from a given val x = List[List[String]]?
105. Result using the following code?
106. Choose description that describes the Scala classes 'scala.AnyRef ' and 'scala.AnyVal'?
107. For given code, Choose correct statement which explains the error?
108. Choose the expression that allows the code to compile
109. Given the type hierarchy defined below, Choose correct statement below?
110. For the type heirachy defined below, Choose the most correct statement below for the output?
111. Which one is false about Futures and Promises?
112. Best description for the variance expression as following?
113. In Scala everything is an Object, No ___?
114. Option that best describes the difference between a var and val definition in Scala?
115. Which one is Web Frameworks of Scala?
116. Which one is not reserved word in Scala?
117. Which statement is false for traits?
118. What's the output?
119. Which one is false about Monads?
120. For the code below, which statement is True?
121. Traits are used to define _ types by specifying the signature of the supported __?
122. Which statement is not correct for trait Iterator?
123. Which code example of Scala collection type for filter is correct?
124. Create an array buffer just like an array, except that you do not need to specify a size. Which implementation will adjust the allocated space automatically?
125. For the code below, Choose the correct statement?
126. Which code snippet correctly represent Type inference on map method of Scala collections?
127. Output for the code below?
128. Output for the code fragment?
129. Correct example of using toArray to convert to an array and toList to convert to a list?
130. Choose statement that is not correct about Scala's List?
131. Reason why the code fails to compile, for the type hierarchy and expressions as following?
132. Which are scala identifiers?
133. When writing the code of a Scala program, you create and interact with objects. To interact with a particular object, you can use a variable that refers to the object. You can do a variable with either a val or var, and assign an object to it. Which option is described by the above statements?
134. The primary tool Scala gives you to organize your programs is the class. A class is a blueprint for objects. Once you do a class, you can create objects from the class blueprint with the keyword new. Which option is described by the above statements?
135. Correct output of given code fragment?
136. The expression List.apply(1,2,3) is the same as?
137. Which are the Keywords used in Scala?
138. Which are correct in context of the above statement?
139. Choose statement that best describes the line def?
140. Which statement is false about Scala?
141. How to override type() java interface method in a scala class?
142. Choose the correct description for the Scala 'Function Type'?
143. Which are function Literal's in Scala?
144. If you want to compare two objects to see if they are equal, you should usually use either ==, or its inverse !=. Which code is true?
145. This trait consists of which of the following methods?
146. Which are the functional trio in Scala?
147. Which one is Accessing scala object fields from java?
148. How to return a value from a scala function?
149. Which statement is about Scala anonymous function?
150. Which are types of function in Scala?
151. Which one is equivalent to the code below?
152. When Extractor object is using the match statement, the unapply method will be __ executed.
153. Which one is not valid in Scala?
154. Often a module is too large to fit comfortably into a single file. When that happens, you can use traits to split a module into separate files. Which one is described by the above statement?
155. Which one describes using Scala class that is defined in a package object from Java?
156. Correct statements that describe a Scala Case class?
157. Scala is ................ with Java. The two languages are interoperable with each other.
158. Choose the correct statement that describes an 'abstract sealed' class?
159. Which one is false about Case Class?
160. Regex class is available in the ................ package.
161. Despite using the same code, the different browser and database modules created really are separate modules. This means that each module has its own contents, including any nested classes. Which option is described by the above statements?
162. Scala bytecode can run on top of Java VM. What is the fundamental difference between Java object.clone() and Scala object.copy()?
163. What is one way to avoid low-level parallelization details?
164. What do you use in ScalaTest to see a detailed diagram of error messages when a test fails?
165. What data type would you use to store an immutable collection of objects that contain a fixed number of varying types?
166. After defining a function in the interpreter, Scala returns the following. What does the () indicate? myfnc: ()Unit
167. What type of number is 1234.e5?
168. When you convert a map to a list using the toList method of the map, the result will be of which type?
169. What type of object does this code create? val x = (1234, "Active")
170. Which is a subclass of all classes?
171. For the for-yield construct, is the scope separate between for-body and yield-body?
172. What term is used to specify a precondition?
173. Which Scala type may throw an exception or a successfully computed value, and is commonly used to trap and propagate errors?
174. What is the data type of y after this code is executed? val y = (math floor 3.1415 * 2)
175. When using pattern matching, which character matches on any object?
176. You have created an array using val. Can you change the value of any element of the array—and why or why not?
177. What do you call objects with immutable state?
178. You have written a Scala script. How would you access command-line arguments in the script?
179. What does this code return? val x = 3; if (x > 2) x = 4 else x = x*2
180. Which statement returns a success or a failure indicator when you execute this code? val MyFuture = Future {runBackgroundFunction() }
181. To denote a parameter that may be repeated, what should you place after type?
182. What is called when a superclass has more than one subclass in Scala?
183. One way to improve code reliability is to use __ , which will evaluate a condition and return an error if the condition is violated.
184. Which statement about if-else-if-else statements is true?
185. What do you call the process of changing the definition of an inherited method?
186. To denote a parameter that may be repeated, what should you place after the type?
187. What is the code below equivalent to? myClass.foreach(println _)
188. What is an advantage of an immutable object?
189. You want to create an iteration loop that tests the condition at the end of the loop body. Which iteration would you use?
190. 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?
191. Which is not a member of the collections hierarchy?
192. Which term makes the contents of packages available without prefixing?
193. If you wanted to find the remainder after division, what operator would you use?
194. What are defined inside a class definition?
195. What defines methods and fields that can then be reused by mixing into classes?
196. When do you need to explicitly state the return type in a function definition?
197. Why would you make a field private?
198. What's the difference between .equals and ==?
199. What is denotes the intersection between two sets?
200. What type of exception is thrown when a precondition is violated?
201. In scala what is precondition?
202. What would you change in this code to make it execute in parallel?
203. What is a free variable?
204. What's the best way to execute code in the background in a separate thread?
205. What value does this code return? x= List(1,2,4); x(1)?
206. Q2. What value does this code return? val m1 = Map("a"->1,"b"->2,"c"->3) m1("a")
207. What is the value of z after executing this code? val y = List('a','b') val z = y::List('c')