• +91 9723535972
  • info@interviewmaterial.com

Kotlin Interview Questions and Answers

Question - What are coroutines in Kotlin?

Answer -

Unlike many other programming languages with similar capabilities, Kotlin doesn't have async and await keywords, and these keywords are not even part of its standard library.

In Kotlin, kotlinx.coroutines is a rich library for coroutines developed by JetBrains. This library contains some high-level coroutine-enabled primitives, including launch, async, and others. Kotlin Coroutines provide us with an API to write our asynchronous code sequentially.

According to Kotlin documentation, Coroutines are like lightweight threads. They are lightweight because while creating them, they don't allocate new threads. Instead, they use predefined thread pools and smart scheduling. Scheduling is the process of determining the work in a sequential process, and it decides which piece of work you will execute next. We can suspend and resume the Coroutines while execution. This means we can have a long-running task, which can be executed one by one. We can pause it any number of times and resume it when required.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners