Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
What is the output of the following code?
fun main() { val numbers = mutableListOf(1, 2, 3, 4, 5) numbers.removeIf { it % 2 == 0 } println(numbers)}
[1, 2, 3, 4, 5]
[1, 3, 5]
[2, 4]
This code will not compile.
Higher-order functions take other functions as parameters or return functions as results.
Higher-order functions are only used for mathematical calculations.
Higher-order functions are not supported in Kotlin.
Higher-order functions are used to create singleton objects.
val is used for variables that can be changed, while "var" is used for variables that are constant.
val is used for variables that are constant, while "var" is used for variables that can be changed.
val and "var" are interchangeable and can be used interchangeably.
val and "var" are not supported in Kotlin.
fun main() { val nullableString: String? = null val length = nullableString?.length ?: -1 println(length)}
0
-1
null
This
A class is a blueprint for creating objects, while an object is a singleton instance of a class.
A class is a singleton instance of an object, while an object is a blueprint for creating classes.
There is no difference between a class and an object in Kotlin.
A class and an object are both used to create instances of a class.
A primary constructor is called before any secondary constructors, while a secondary constructor is called before the primary constructor.
A primary constructor is defined inside the class definition, while a secondary constructor is defined outside the class definition.
A primary constructor takes parameters that are used to initialize properties, while a secondary constructor can have additional logic or functionality.
There is no difference between a primary and a secondary constructor in Kotlin.
??
::
!!
//
fun main() { val numbers = listOf(1, 2, 3, 4, 5) val filteredNumbers = numbers.filter { it % 2 == 0 } println(filteredNumbers)}
fun myFunction()
fun myFunction(): String
fun myFunction(): Int = 42
All of the above
{x, y -> x + y}
(x, y) => x + y
[x, y] -> x + y
(x, y) -> {x + y}