Scala framework-Scala Multiple/Choice Questions Set 1 Sample Test,Sample questions

Question:
 Identifiers in Scala are names given to -

1.Classes or objects

2.Methods

3.Objects

4.All of these


Question:
 Is 'sealed' a keyword in Scala -

1.Yes

2.No

3.Error

4.None of These


Question:
 Is the following identifier valid?

12Scala_3

1.Yes

2.No

3.Error

4.None of these


Question:
 Scala programming language was developed by -

1.James Gosling

2.Martin Odersky

3.Dennis MacAlistair Ritchie

4.Guido van Rossum


Question:
 The correct syntax for creating Single line comments in Scala is,

1.//

2.<!-- -- >

3./* */

4.%%


Question:
 The semicolon (;) in Scala is -

1.Necessary, failing to write will not mark the end of line

2.Not required, it is treated as a character

3.Optional, end of the line does not require ;

4.None of these


Question:
 The total number of keywords in Scala are -

1.45

2.34

3.39

4.52


Question:
 What is the scope of a local variable in Scala?

1.Whole program

2.A method is it declared in

3.Class/object containing it

4.All of the above


Question:
 Which of these is not a primary data type in Scala -

1.Integer

2.String

3.Array

4.Char


Question:
A final method can be applied on?

1.Variables

2.Classes

3.Functions

4.All of the above


Question:
Based on Type Casting, which of these conversions is lossy or invalid?

1.Character -> Float

2.Float -> Long

3.Short -> Integer

4.Integer -> Double


Question:
Converting Character to Integer will return

1.Error

2.Random integer value

3.ASCII value of the character

4.None of the above


Question:
Default values of string type when it is not initialized -

1.0

2.Null

3.None

4." "


Question:
Explicit Conversion is -

1.Done by the compiler itself

2.Defined by the user

3.Both A and B

4.None of the above


Question:
Find the result of the following code block -

(3 + 4 * 5) >>>  1

1.43

2.11

3.12

4.120


Question:
How many types of operators are present in Scala?

1.5

2.2

3.6

4.8


Question:
In Scala, can you return two values?


1.Yes

2.No

3.Error

4.None of These


Question:
Is Java required before installing Scala on the system?

1.Yes

2.No

3.Error

4.None of these


Question:
Lazy initialization is -

1.Creating variables using the lazy keyword

2.Done only on immutable variables

3.Calculated at its first access

4.All of the above


Question:
Literal Identifier is -

1.String literal used as an identifier in Scala

2.Value literal used as an identifier in Scala

3.Numeric literal used as an identifier in Scala

4.None of These


Question:
Literals in Scala are ___.

1.Name of the variables

2.A literal is a value that can be assigned to a variable

3.The type of the values

4.None of these


Question:
Logical operators in Scala are used to -

1.Perform a comparison of values

2.Perform logical operation on the boolean value

3.Return a value

4.None of These


Question:
Relation operators are -

1.Return a relative value

2.Used to define the comparison between the two operators

3.Create new values based on the relation

4.None of These


Question:
Scala stands for ___.

1.Scalable language

2.Scripted advanced language

3.Sequential language

4.None of These


Question:
Statement returned by function when no values are returned in Scala -




None of these

1.No value

2.Unit

3.Int

4.None of These


Question:
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)
    }
}

1.a = 454.32138988 b = 454.32138988152344

2.a = 454.32138 b = 454.3213806152344

3.a = 454.32138 b = 454.32138

4.Error


Question:
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))
    }
}

1.54

2.Error

3.119

4.65


Question:
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)+"	")
                }
            }
        }
    }
}

1.3 3

2.2 0

3.0 2

4. 1 1


Question:
The final keyword in Scala is used to -

1.Define a variable whose value cannot be further changed

2.Create a new variable

3.Special inaccessible value in Scala

4.None of these


Question:
The getClass() method is used to -

1.Extract the class of the given number

2.Extract the value of the variable

3.Extract the memory location of the variable

4.All of the Above


Question:
The Scala compiler starts executing from -

1.The first line of code

2.main() method

3. main class

4.End of code


Question:
The size of integer data type in Scala is -

1.256 bits

2.4 bits

3.32 bits

4.64 bits


Question:
Using a keyword as a value will lead to -

1.Error

2.Compile with the NULL value

3.Warning

4.None of the above


Question:
What is the output of following code?

val i = 43
i = 231
printf(i)

1.231

2.43

3.0

4.Error


Question:
What is the paradigm of the Scala programming language?


1.Object-oriented

2.Statically Types

3.Functional

4.All of the above


Question:
What is the range defined by the below statement -

range(13, 17, 2)

1.13 14 15 16 17

2.13 14 15 16

3.13 15

4.13 15 17


Question:
What is the symbolic operator in Scala?

1.Predefined sets that can handle a specific task

2.Are reserved to a specific use

3.Symbols that have a specific task that they perform when called in a Scala program

4.All of these


Question:
What is the use of the "&=" operator in Scala -

1.Bitwise operator

2.Arithmetic operator

3.Bitwise Assignment operator

4.None of these


Question:
Which class is the super-class of all classes in Scala?

1.Ref

2.AnyRef

3.Any

4.AnyVar


Question:
Which is not a Scala method for printing text on the screen?

1.print()

2.printf()

3.printl()

4.println()


Question:
Which of the following are not present in Scala?



1.Closures

2.Monads

3.Traits

4.None of these


Question:
Which of the following is not a feature of Scala?

1.Type inference

2.Lazy Computation

3.High order function

4.None of the above


Question:
Which of these is not a keyword in Scala?

1.int

2.var

3.forsome

4.package


Question:
Which of these is not a type of identifier -

1.Alphanumeric identifier

2.Operator identifier

3.Literal identifier

4.Value identifier


Question:
Which Scala keyword is used to initialize a variable?




1.int

2.var

3.value

4.None


Question:
Which type class does not inherit AnyVar?

1.Char

2.Int

3.Float

4.Pointer


Question:
Which type in Scala is a subtype of all types -



1.Int

2.Ref

3.Boolean

4.Nothing


Question:
Which type of typecasting is done by the compiler?

1.Implicit Conversion

2.Explicit Conversion

3.Instance conversion

4.None of these


Question:
Which variable in Scala can save memory while declaring variables?





1.Mutable variables

2.Lazy Variables

3.Inherited Variables

4.None of these


Question:
Why is Double better than Float values?

1.It can store double-precision values providing more accurate data to be stored.

2.It stores 64 bits values instead of 32 bits from a float.

3.Float Values are better

4.Both A and B


More MCQS

  1. Scala Multiple Choice Questions
  2. Scala Multiple-Choice Questions Set 1
  3. Scala Multiple-Choice Questions Set 2
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!