
Kotlin Quiz - Find the Output

Quiz
•
Computers
•
Professional Development
•
Hard
Nisha V
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? fun square(num: Int): Int { return num * num } fun main() { val result = square(5) println("The square of 5 is: $result") }
The square of 5 is: 10
25
The square of 5 is: 25
square(5)
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? fun factorial(n: Int): Int { return if (n == 0) 1 else n * factorial(n - 1) } fun main() { val num = 5 val result = factorial(num) println("Factorial of $num is $result") }
120
25
Factorial of 5 is 120
5
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? fun add(a: Int, b: Int): Int = a + b fun calculate(x: Int, y: Int, operation: (Int, Int) -> Int): Int { return operation(x, y) } fun main() { val result = calculate(10, 5, ::add) println("Result: $result") }
10
15
Result: 15
Error
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? fun main() { val square = { x: Int -> x * x } val result = square(6) println("Square is: $result") }
36
6
Square is: 36
Error
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? inline fun greet(block: () -> Unit) { println("Before greeting") block() println("After greeting") } fun main() { greet { println("Hello, Nisha!") } }
Before greeting Hello, Nisha! After greeting
Hello, Nisha! After greeting
Only Before greeting
Compilation Error
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? val age = 18 if (age < 13) { println("Child") } else if (age in 13..17) { println("Teenager") } else { println("Adult") }
Teenager
Adult
Child
Error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? val day = 3 when (day) { 1 -> println("Sunday") 2 -> println("Monday") 3 -> println("Tuesday") else -> println("Invalid day") }
Monday
Tuesday
3
Invalid day
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
C Module 1 Quiz

Quiz
•
Professional Development
12 questions
JAVA control Structure

Quiz
•
Professional Development
15 questions
FORMATIVE ASSESSMENT 2 OOPS

Quiz
•
Professional Development
12 questions
StreamQuiz

Quiz
•
Professional Development
10 questions
php- basics

Quiz
•
Professional Development
10 questions
Kotlin 1

Quiz
•
Professional Development
13 questions
MindSpace Computers C Quiz-1 2025

Quiz
•
Professional Development
10 questions
C Code Master lvl 2 A

Quiz
•
Professional Development
Popular Resources on Wayground
12 questions
Unit Zero lesson 2 cafeteria

Lesson
•
9th - 12th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
20 questions
Lab Safety and Equipment

Quiz
•
8th Grade
13 questions
25-26 Behavior Expectations Matrix

Quiz
•
9th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
11 questions
All about me

Quiz
•
Professional Development
10 questions
How to Email your Teacher

Quiz
•
Professional Development
5 questions
Setting goals for the year

Quiz
•
Professional Development
14 questions
Disney Trivia

Quiz
•
Professional Development
14 questions
2019 Logos

Quiz
•
Professional Development
7 questions
How to Email your Teacher

Quiz
•
Professional Development
11 questions
NFL Football logos

Quiz
•
KG - Professional Dev...
20 questions
Employability Skills

Quiz
•
Professional Development