Search test library by skills or roles
⌘ K

Adaface Sample Kotlin Questions

Here are some sample Kotlin questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

Asynchronous Task Sequencing
Coroutines
Exception Handling
Lambda Functions
Solve
In Kotlin, you are tasked with creating a function executeTasksSequentially that runs a list of suspendable tasks sequentially within a coroutine context. Each task is a lambda function that can perform an asynchronous operation and potentially throw an exception. The function should handle these exceptions and continue executing the remaining tasks. However, a crucial line is missing in the function implementation, and you need to identify which line correctly completes it.
            
            Here's the incomplete function:
 image
This function is particularly useful in scenarios where multiple asynchronous tasks need to be run in order, such as processing a sequence of network requests or database transactions.
A: task.invoke()
            B: withContext(Dispatchers.IO) { task() }
            C: async { task() }.await()
            D: launch { task() }.join()
            E: task()
            F: delay(1000); task()

Medium

Completing Recursive Search
Recursion
Data classes
Control Flow
Solve
In Kotlin, you are asked to complete the implementation of a function searchNodeByName which recursively searches for a node by its name within a tree structure represented by instances of the data class Node(val name: String, val children: List<Node>). However, a crucial line is missing in the implementation, and your task is to identify which line correctly completes the function.
            
            Here's the incomplete function:
 image
A: return searchNodeByName(it, nodeName)
            B: if (searchNodeByName(it, nodeName) != null) return searchNodeByName(it, nodeName)
            C: try { return searchNodeByName(it, nodeName) } catch (e
            D: if (it.name == nodeName) return it
            E: it.name == nodeName
            F: searchNodeByName(it, nodeName)

Medium

Dependency Resolution
Recursion
Data classes
Lambda expressions
Solve
In Kotlin, you are tasked with designing a system that manages software dependencies. Each software package is represented by a Package data class, which includes a name and a list of dependencies (other Package objects). The main function, resolveDependencies, should recursively gather all unique dependencies for a given package, including dependencies of dependencies, and return them in a set to avoid duplication.
            
            Here's the initial setup for the data classes and function:
 image
Consider the following structure of packages with nested dependencies:
 image
If println(resolveDependencies(packageE)) is called, what is the expected output?

Easy

Secondary Constructor
OOPs
Solve
What does the following Kotlin code print?
 image
🧐 Question🔧 Skill

Medium

Asynchronous Task Sequencing
Coroutines
Exception Handling
Lambda Functions

2 mins

Kotlin
Solve

Medium

Completing Recursive Search
Recursion
Data classes
Control Flow

2 mins

Kotlin
Solve

Medium

Dependency Resolution
Recursion
Data classes
Lambda expressions

3 mins

Kotlin
Solve

Easy

Secondary Constructor
OOPs

2 mins

Kotlin
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
Asynchronous Task Sequencing
Coroutines
Exception Handling
Lambda Functions
Kotlin
Medium2 mins
Solve
Completing Recursive Search
Recursion
Data classes
Control Flow
Kotlin
Medium2 mins
Solve
Dependency Resolution
Recursion
Data classes
Lambda expressions
Kotlin
Medium3 mins
Solve
Secondary Constructor
OOPs
Kotlin
Easy2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1500+ companies in 80+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️