Complete the code to declare a singleton object named Logger.
object [1] {
fun log(message: String) {
println(message)
}
}object keyword.The keyword object declares a singleton object named Logger.
Complete the code to call the log function of the Logger object.
fun main() {
[1].log("Hello, Kotlin!")
}To call the log function, use the object name Logger.
Fix the error in the object declaration syntax.
object [1] { fun greet() = println("Hi!") }
Object declarations do not use parentheses. Remove them and use a valid name like Greeter.
Fill both blanks to declare an object with a property and a function.
object [1] { val [2] = "Kotlin" fun printName() = println(name) }
The object is named AppConfig and the property used in the function is name.
Fill all three blanks to create an object with a mutable property and a function to update it.
object [1] { var [2] = 0 fun [3](value: Int) { count = value } }
val instead of var.The object is Counter, the mutable property is count, and the function to update it is updateCount.
