
Kotlin Quiz - Find the Output
Authored by Nisha V
Computers
Professional Development

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
A glimpe of a microprocessor vs microcontroller
Quiz
•
University - Professi...
10 questions
DECI - Week 2 - round
Quiz
•
Professional Development
15 questions
C PROGRAMMING BASICS-QUIZ-1
Quiz
•
Professional Development
11 questions
DECI - M3 - W4 - Round2
Quiz
•
Professional Development
9 questions
Advanced JS II
Quiz
•
Professional Development
12 questions
квиз нг
Quiz
•
Professional Development
10 questions
python quiz
Quiz
•
6th Grade - Professio...
10 questions
Python Collections
Quiz
•
Professional Development
Popular Resources on Wayground
8 questions
Spartan Way - Classroom Responsible
Quiz
•
9th - 12th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
14 questions
Boundaries & Healthy Relationships
Lesson
•
6th - 8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
3 questions
Integrity and Your Health
Lesson
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
9 questions
FOREST Perception
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
Discover more resources for Computers
15 questions
LOTE_SPN2 5WEEK3 Day 2 Itinerary
Quiz
•
Professional Development
6 questions
Copy of G5_U6_L5_22-23
Lesson
•
KG - Professional Dev...
10 questions
March Quiz
Quiz
•
Professional Development
5 questions
Copy of G5_U6_L8_22-23
Lesson
•
KG - Professional Dev...
10 questions
suffixes FUL OR LESS
Quiz
•
Professional Development