Q282
Why does not this code snippet compile? class Cat (name: String) fun greet() println("Hello this.name") fun main() val thunderCat = Cat("ThunderCat") thunderCat.greet()
A.
Because name is a class parameter, not a property-it is unresolved main().
AnswerB.
In order to create an instance of a class, you need the keyword new
C.
The reference to name needs to be scoped to the class, so it should be this.name
D.
Classes cannot be immutable. You need to change var to val
Answer: Option A
Solution
Answer: Option A
No explanation is given for this question Let's Discuss on Board