Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic Scala programming questions. I will give a thumb up, thank you! Consider the class below. Identify each member of the class with the attributes

Basic Scala programming questions. I will give a thumb up, thank you!

Consider the class below.

image text in transcribed

Identify each member of the class with the attributes that apply to it.

image text in transcribed

2:

image text in transcribed

class BarkingDog(val name: String, val breed:String, val age: Int ) [ A list of shouts for the dog val listofShouts = List ("Wuffluff", "Bowliowllow", "ARuff ARuff", "Ruoff", "Meow") The current shout private var idx = 0 def bark() -{ /t Print the bark println(s"$(this.name, a proud $this.breed says $listofShouts (idx)!") /* Increment the index but wrap around to to avoid embarassing exceptions */ this. idx (this. idx + 1) %(listOfShouts. Iength) /* This is only possible because idx is breed Choose... icdb bark Choose... Choose... Choose Private Immutable Integer Check Public Immutable String Private Mutable Integer Public Member Function Private Member Function ublic: MuiableSiy Private Immutable String Selecti def foo(K Int) Int-x2 def bar(y: String): String - "Hello"y def baz(z: String): Int - val str1bar(z) val sizl-str1.size foo(sizl) hich of the following satements about hese funcions are rue elect one or more: a. Calling foo(bar(z) will result in a type mismatch error because the output type of bar (String) is not the same as the input type of foo (Int). b. baz takes in an input string and returns the number equaling the size of input string plus 7 C. Although foo's argument x is typed to be an Int, scala will correctly execute a call such as fool World") d. The value siz1 in baz will have the type String e. Changing the last statement of baz from foo(sizl) to eturn foo(sizl) does not change its meaning

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago