Maersk - Python Scala


 Python Scala

 

1.   What are the Scala variables?

o  val myVal: Int=1;

o  var myVar: Int=0;

o  Both A and B

o  None of the above

2.   Which function overloads the + operator?

o  __plus__()

o  __sum__()

o  __add__()

o  None of the above

3.   Private members of a python class cannot be accessed.

o  TRUE

o  FALSE

4.   How should we end a stream to calculate sum of elements?

o  Sink.fold[Int, Int](0)(_+_)

o  Sink.map(_+_)

o  Sink.sum_

o  Sink.sum[Int](_)

5.   What will be the output of the following Python code?

             class Demo:

                   def__init__(self):

                       self.a = 1

                       self.__b = 1

                   def get(self):

                       return self.__b

             obj = Demo()

            print(obj.get())

o  The program has an error because b is private and display(self) is returning a private member

o  The program runs fine and 1 is printed

o  The program has an error because b is private and hence can’t be printed

o  The program has an error because there isn’t any function to return self.a

6.   What is the advantage of Scala?

o  High scalability

o  Less error prone functional style

o  High maintainability and productivity

o  All of the mentioned

7.   What is the biggest reason for the use of polymorphism?

o  The program will have more elegant design and will be easier to maintain and update

o  It allows the programmer to think at a more abstract level

o  Program code takes up less space

o  There is less program code to write.

8.   Which of these is not a fundamental feature of OOP?

o  Instantiation

o  Inheritance

o  Polymorphism

o  Encapsulation

No comments:

Post a Comment