Olete.in
Articles
Mock Tests
🧪 Scala framework MCQ Quiz Hub
Scala Multiple-Choice Questions Set 1
Choose a topic to test your knowledge and improve your Scala framework skills
1. Scala programming language was developed by -
James Gosling
Martin Odersky
Dennis MacAlistair Ritchie
Guido van Rossum
2. What is the paradigm of the Scala programming language?
Object-oriented
Statically Types
Functional
All of the above
3. Scala stands for ___.
Scalable language
Scripted advanced language
Sequential language
None of These
4. Which of the following is not a feature of Scala?
Type inference
Lazy Computation
High order function
None of the above
5. Is Java required before installing Scala on the system?
Yes
No
Error
None of these
6. The semicolon (;) in Scala is -
Necessary, failing to write will not mark the end of line
Not required, it is treated as a character
Optional, end of the line does not require ;
None of these
7. The Scala compiler starts executing from -
The first line of code
main() method
main class
End of code
8. Which of the following are not present in Scala?
Closures
Monads
Traits
None of these
9. The correct syntax for creating Single line comments in Scala is,
//
<!-- -- >
/* */
%%
10. The correct output of the following code is, object MyClass { def main(args: Array[String]) { var i,j=0 for(i <- 0 to 3){ for(j <- 0 until 2){ if(i + j == 3){ print((i*j)+" ") } } } } }
3 3
2 0
0 2
1 1
11. Which of these is not a primary data type in Scala -
Integer
String
Array
Char
12. The size of integer data type in Scala is -
256 bits
4 bits
32 bits
64 bits
13. Why is Double better than Float values?
It can store double-precision values providing more accurate data to be stored.
It stores 64 bits values instead of 32 bits from a float.
Float Values are better
Both A and B
14. Which class is the super-class of all classes in Scala?
Ref
AnyRef
Any
AnyVar
15. Which type class does not inherit AnyVar?
Char
Int
Float
Pointer
16. The correct output of the below code block is - object MyClass { def main(args: Array[String]) { var a : Float = 454.32138988f var b : Double = a; printf("a = " + a + " b = " + b) } }
a = 454.32138988 b = 454.32138988152344
a = 454.32138 b = 454.3213806152344
a = 454.32138 b = 454.32138
Error
17. Default values of string type when it is not initialized -
0
Null
None
&quot; &quot;
18. Which type in Scala is a subtype of all types -
Int
Ref
Boolean
Nothing
19. Statement returned by function when no values are returned in Scala - None of these
No value
Unit
Int
None of These
20. In Scala, can you return two values?
Yes
No
Error
None of These
21. What is the range defined by the below statement - range(13, 17, 2)
13 14 15 16 17
13 14 15 16
13 15
13 15 17
22. Which is not a Scala method for printing text on the screen?
print()
printf()
printl()
println()
23. What is the output of following code? val i = 43 i = 231 printf(i)
231
43
0
Error
24. Literals in Scala are ___.
Name of the variables
A literal is a value that can be assigned to a variable
The type of the values
None of these
25. Based on Type Casting, which of these conversions is lossy or invalid?
Character -&gt; Float
Float -&gt; Long
Short -&gt; Integer
Integer -&gt; Double
26. Which type of typecasting is done by the compiler?
Implicit Conversion
Explicit Conversion
Instance conversion
None of these
27. Explicit Conversion is -
Done by the compiler itself
Defined by the user
Both A and B
None of the above
28. The getClass() method is used to -
Extract the class of the given number
Extract the value of the variable
Extract the memory location of the variable
All of the Above
29. Converting Character to Integer will return
Error
Random integer value
ASCII value of the character
None of the above
30. Which Scala keyword is used to initialize a variable?
int
var
value
None
31. Lazy initialization is -
Creating variables using the lazy keyword
Done only on immutable variables
Calculated at its first access
All of the above
32. The total number of keywords in Scala are -
45
34
39
52
33. Which of these is not a keyword in Scala?
int
var
forsome
package
34. Using a keyword as a value will lead to -
Error
Compile with the NULL value
Warning
None of the above
35. Is 'sealed' a keyword in Scala -
Yes
No
Error
None of These
36. Identifiers in Scala are names given to -
Classes or objects
Methods
Objects
All of these
37. Which of these is not a type of identifier -
Alphanumeric identifier
Operator identifier
Literal identifier
Value identifier
38. Is the following identifier valid? 12Scala_3
Yes
No
Error
None of these
39. Literal Identifier is -
String literal used as an identifier in Scala
Value literal used as an identifier in Scala
Numeric literal used as an identifier in Scala
None of These
40. The correct output of the following code is - object myObject { def main(args: Array[String]) { var _value1 = 54 var 3value_2 = 65 println("The sum of two values is " + (_value1 + value_2)) } }
54
Error
119
65
41. Which variable in Scala can save memory while declaring variables?
Mutable variables
Lazy Variables
Inherited Variables
None of these
42. How many types of operators are present in Scala?
5
2
6
8
43. Logical operators in Scala are used to -
Perform a comparison of values
Perform logical operation on the boolean value
Return a value
None of These
44. What is the use of the "&=" operator in Scala -
Bitwise operator
Arithmetic operator
Bitwise Assignment operator
None of these
45. Find the result of the following code block - (3 + 4 * 5) >>> 1
43
11
12
120
46. Relation operators are -
Return a relative value
Used to define the comparison between the two operators
Create new values based on the relation
None of These
47. What is the symbolic operator in Scala?
Predefined sets that can handle a specific task
Are reserved to a specific use
Symbols that have a specific task that they perform when called in a Scala program
All of these
48. The final keyword in Scala is used to -
Define a variable whose value cannot be further changed
Create a new variable
Special inaccessible value in Scala
None of these
49. A final method can be applied on?
Variables
Classes
Functions
All of the above
50. What is the scope of a local variable in Scala?
Whole program
A method is it declared in
Class/object containing it
All of the above
Submit