Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I and 3 C 2 and3 D: none are true Question 3: Consider the Scala definitions: cl

ID: 3908202 • Letter: I

Question

I and 3 C 2 and3 D: none are true Question 3: Consider the Scala definitions: class A t def f (n:Int):Int- if (n -1) 1 elsen f (n 1) class B extends A override def f (n: Int): Int = { println (n); super. f (n) } val b:B neu B O println (b.f (3)) What happens when this program is compiled and executed? A : The program compiles and runs successfully and prints 3, 6 on separate lines. The program compiles and runs successfully and prints 3, 2, 1, 6 on separate lines. C The program fails to compile because the recursive invocation of f inside the definition of method f in class A cannot refer to the other class's f method. D: The program compiles and runs successfully and prints 6 E : The program compiles, but fails at runtime when making a recursive call to f. Question 4: Consider the Scala definitions: object 0 def f(x: Int) // f1, x1 def g(x:Int): Int = // gì, x2 if (x0)x // x3, x4 else xte(x)

Explanation / Answer

Question 3)

B) The program compiles and runs successfully and prints 3,2,1,6 on separate lines .

Question 4)

A) x3 is statically bound to x2 is a false statement

Question 5)

B) Program fails due to a pattern matching error .

PLEASE RATE !!
THanks !

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote