Name: Serial Number: 500 B: (1), (2), and (3) is accepted by the Scala compiler C: (1) and (2) are accepted by the Scala compiler; (3) is not accepted D: (2) and (3) are accepted by the Scala compiler; (1) is not accepted E: (1) is accepted by the Scala compiler; (2) and (3) are not accepted Question 7: Consider the Scala code: val q = (x: Int) => ((y: Int) => (x,y) ) What will happen when (q(10)) (20) is executed? A: Returns (20, 10). B: Returns (30,30). C: Returns (10,20). D: Returns 20. E: Returns 10. Question 8: Consider the following code in Perl: my $x = 10; my $y = 1; sub f { print ("x= $x\n"); if ($y > 0) { 8 (); } sub g { my $x = 20; $y = $y - 1; f (); } f (); What will be printed when this program is executed? Recall that Perl uses static scope with variables declared using my. A: x= 10 and x = 190 B: x= 10 and x = 20 C: x= 10 and x = 10 D: x = 20 and x = 20 E: x= 10 and x = 9 Question 9: Consider the following code in an unspecified language with Scala-like syntax: val n = 3 def createList (init: Int): List [Int] = { def aux (start: Int, count: Int): List [Int] = { if (count == 0) {

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Scala programming
Serial Number: 500
my $x = 20;
$y = $y 1;
f ();
tratar
}
f ();
What will be printed when this program is executed? Recall that Perl uses static scope with variables declared
using my.
A: x= 10 and x = 190
B: x= 10 and x = 20
C: x= 10 and x = 10
D: x = 20 and x = 20
E: x= 10 and x = 9
Question 9: Consider the following code in an unspecified language with Scala-like syntax:
val n = 3
def createList (init: Int) : List [Int] = {
def aux (start: Int, count: Int): List [Int] = {
if (count == 0) {
Name:
B: (1), (2), and (3) is accepted by the Scala compiler
C: (1) and (2) are accepted by the Scala compiler; (3) is not accepted
D: (2) and (3) are accepted by the Scala compiler; (1) is not accepted
E: (1) is accepted by the Scala compiler; (2) and (3) are not accepted
Question 7: Consider the Scala code:
val q = (x: Int) => ((y: Int) => (x,y) )
What will happen when (q(10)) (20) is executed?
A: Returns (20, 10).
B: Returns (30,30).
C: Returns (10,20).
D: Returns 20.
E: Returns 10.
Question 8: Consider the following code in Perl:
my $x = 10;
my $y = 1;
sub f {
print ("x = $x\n");
if ($y > 0) {
g ();
}
}
sub g {
Transcribed Image Text:Serial Number: 500 my $x = 20; $y = $y 1; f (); tratar } f (); What will be printed when this program is executed? Recall that Perl uses static scope with variables declared using my. A: x= 10 and x = 190 B: x= 10 and x = 20 C: x= 10 and x = 10 D: x = 20 and x = 20 E: x= 10 and x = 9 Question 9: Consider the following code in an unspecified language with Scala-like syntax: val n = 3 def createList (init: Int) : List [Int] = { def aux (start: Int, count: Int): List [Int] = { if (count == 0) { Name: B: (1), (2), and (3) is accepted by the Scala compiler C: (1) and (2) are accepted by the Scala compiler; (3) is not accepted D: (2) and (3) are accepted by the Scala compiler; (1) is not accepted E: (1) is accepted by the Scala compiler; (2) and (3) are not accepted Question 7: Consider the Scala code: val q = (x: Int) => ((y: Int) => (x,y) ) What will happen when (q(10)) (20) is executed? A: Returns (20, 10). B: Returns (30,30). C: Returns (10,20). D: Returns 20. E: Returns 10. Question 8: Consider the following code in Perl: my $x = 10; my $y = 1; sub f { print ("x = $x\n"); if ($y > 0) { g (); } } sub g {
Serial Number: 500
Name:
The precise behavior of each instruction can be seen in the run method.
What is printed when the run (myprog, Nil) is executed?
A: 6 and then 48.
B: 4 and then 60
C: 4 and then 48.
D: 6 and then 60
E: 6 and then 30
Question 4: Consider the Scala code:
val q= (x: Int) => ((y: Int) => (x,y) )
What is the type of q?
A: Int > Int
B: (Int, Int) => (Int, Int)
C: Int-> (Int-> (Int, Int))
D: Int
E: (Int, Int)
Question 5: Consider the Scala code:
var x = 10
val q= { x = x * 2; () => { x = x * 3; println (x) } }
var x = 11
What is the type of q?
A: Int=> Int
B: ()=>Int
C: ()=>Unit
D: Int
E: Int->Unit
Question 6: Consider the following Scala code (where... indicates omitted code):
class Shape
{...}
class Triangle extends Shape {...}
val shapes: Array [Shape] = Array (new Triangle, new Triangle) // (1)
val triangles: Array [Triangle] = shapes
// (2)
// (3)
val shapes2: Array [Shape] = triangles
Which of the above lines of code are accepted by the Scala compiler when it typechecks the code? You should
answer for (2) based on the variable shapes having type Array [Shape]. Similarly, you should answer for (3) based
on the variable triangles having type Array [Triangle].
A: (1) and (3) are accepted by the Scala compiler; (2) is not accepted
Transcribed Image Text:Serial Number: 500 Name: The precise behavior of each instruction can be seen in the run method. What is printed when the run (myprog, Nil) is executed? A: 6 and then 48. B: 4 and then 60 C: 4 and then 48. D: 6 and then 60 E: 6 and then 30 Question 4: Consider the Scala code: val q= (x: Int) => ((y: Int) => (x,y) ) What is the type of q? A: Int > Int B: (Int, Int) => (Int, Int) C: Int-> (Int-> (Int, Int)) D: Int E: (Int, Int) Question 5: Consider the Scala code: var x = 10 val q= { x = x * 2; () => { x = x * 3; println (x) } } var x = 11 What is the type of q? A: Int=> Int B: ()=>Int C: ()=>Unit D: Int E: Int->Unit Question 6: Consider the following Scala code (where... indicates omitted code): class Shape {...} class Triangle extends Shape {...} val shapes: Array [Shape] = Array (new Triangle, new Triangle) // (1) val triangles: Array [Triangle] = shapes // (2) // (3) val shapes2: Array [Shape] = triangles Which of the above lines of code are accepted by the Scala compiler when it typechecks the code? You should answer for (2) based on the variable shapes having type Array [Shape]. Similarly, you should answer for (3) based on the variable triangles having type Array [Triangle]. A: (1) and (3) are accepted by the Scala compiler; (2) is not accepted
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

please answer other questions as well

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY