Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
123 views
9 pages
Kotlin Interview Cheat Sheet
Uploaded by
cobesim739
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Kotlin interview cheat sheet For Later
Download
Save
Save Kotlin interview cheat sheet For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
123 views
9 pages
Kotlin Interview Cheat Sheet
Uploaded by
cobesim739
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Kotlin interview cheat sheet For Later
Carousel Previous
Carousel Next
Download
Save
Save Kotlin interview cheat sheet For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
arias asa Kolin Interview Cheat Sheat. Two Months ago when i started appearing... [by Kapil Vi | Oct, 2021 | Macium openinaoe en Kapil Vij 102 Followers About Caton) C) Kotlin Interview Cheat Sheet @© ‘015 027 - sminreas K Kotlin Interview Questions ‘Two Months ago when i started appearing in interviews I used to get blank in some of tricky questions in Kotlin even when i spend some time coding in Kotlin in live projects. But I kept collecting questions which are not mentioned anywhere under single umbrella. So i decided to collate some of important questions currently being asked for people who gets little time to prepare for interviews. This article will help you clear kotlin questions with ease and it's hardly a 15 mins read for beginners. Here You go... Q1. What is the difference between val and var? var is like a general variable and can be assigned multiple times and is known as the hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73 19Open inepp e Q2. What is the difference between val and const val? const and val both represents the immutability and read only values and act as final keyword in java. val keyword must be used to declare for run time values and const keyword must be used to declare compile time values. Q3. What is Difference between setValue() and PostValue() in MutableLiveData? setvalue() method must be called from the main thread. But if you need set a value from a background thread, postvaiue() should be used. Q4. How to check if lateinit property is initialized or not? You can check if the lateinit variable has been initialized or not before using it with the help of isInitialized() method. It returns true if the lateinit property has been i otherwise false. ‘this: :variablenane. istnitializes lateint initialized hosted with © by Githiub view raw QS. When to use lateinit and lazy keywords in kotlin? Lateinit is used with mutable, while lazy is used with immutable Jateinit > 2 private lateinit var display : DisplayAdapter 2 2 // Sf you use above without initializing, 1t will throw UinitializedPropertyAccessException Intent hosted wth © by Github view raw lazy > Itinitializes variable only when it is required for the first time. 2 private val githubipiservice : Githubapiservice by lazy { 2 _-Retrofitchient.getsithubapiservice() 3} Inzy hosted wth by Gittub view rae Lazy :- There are certain classes whose object initialization is very heavy and so much time taking that it results in the delay of the whole class creation process. Q6. Whats difference between companion object and object?Companion Object is initialized when class is loaded. But Object is initialized lazily by default — when accessed for the first time. hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73parva as Kotin Interview Cheat Shest Two Months ago when i started appearing... |by Kapil Vij | ct, 2021 | Mecium Openinapp en crash even if variable reference you are holding is null. var variable: String? = null variable?.replace(“x”, “z”) Please note we have not initialized variable above, but it will not throw NullPointerException as Safe call operator is used. But in case of Non-Null Assertion, if you call any method on its reference it will throw KotlinNullPointerException. variable!!.replace(“”, “2”) Q8. What are data classes in kotlin? data class Person(val name: String) 2 var age: Int = @ 3) data class hosted with © by GitHub view raw Only the property name will be used inside the toStringQ, equals(), hashCode(), and copy() implementations. While two Person objects can have different ages, they will be treated as equal for above example. Q9. Why kotlin classes are final by default ? Design and document for inheritance or else prohibit it — Core principle from book Effective Java by Joshua Bloch’s In Simple words -> If classes were open by default and we would forget to mark class as final — (troubles might happen), but when we forget to mark class as open and try to extend it — we will be notified (no trouble). QUO. Difference between == operator and === operator? The == operator is used to compare the values of variables but check whether references of the variable is equal or not. And in the case of primitive types, the --- operator also checks for the value and not operator is used to reference, Please note both will result in same in case primitive data types 2 val number = Integer(2) 2. val anotherNunber = Integer(1) 3 number notherwunber // true (structural equality) htps:ikapivi. medium. convkoln-intrview-cheat-shaet-c6267850ba73parva as Kotin Interview Cheat Shest Two Months ago when i started appearing... |by Kapil Vij | ct, 2021 | Mecium Openinapp e Q11. Access/Visibility Modifiers in Kotlin Four types of access modifiers * protected: visible inside that particular class or file and also in the subclass of that particular class where it is declared. © private: visible inside that particular class or file containing the declaration. * internal: visible everywhere in that particular module. + public: visible to everyone. Note: By default, the visibility modifier in Kotlin is public. Q12. What are extension functions in Kotlin? Extension Function provides an option to “add” methods to class without inheriting a class. The created extension functions are used as a regular function inside that class. See Example below: 2 fun View mideview() ( 2 ‘this.visibility = View.GONE BD Extension Function hosted with © by GitHub view raw Now you can call this same method on any type of view directly on its reference. e.g. textView hideView( Q13. What are inline functions ? Inline function instruct compiler to insert complete body of the function wherever that function got used in the code. To use an Inline function, all you need to do is just add an inline keyword at the beginning of the function declaration. Q14. What are scope functions in Kotlin ? Scoped functions are functions that execute a block of code within the context of an object. There are five scoped functions in kotlin : let, run, with, also and apply. ‘The scope functions differ by the result they return: * apply and also return the context object. So they can be used in chaining function calls on the same object after them. They also can be used in return statements of functions hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73paras asa Kotin Interview Cheat Shest Two Months ago when i started appearing... |by Kapil Vij | Oct, 2021 | Mecium openinaoe e Learn more avout scope Luncuons nere. Q15. What are sealed classes in kotlin? Sealed classes are similar to sous classes: the set of values for an enum type is also restricted, but each enum constant exists only as a single instance, whereas a subclass of asealed class can have multiple instances, each with its own state. To declare a sealed class or interface, put the scaled modifier before its name: 2 sealed interface Error 3. sealed class 1oError(): Error 5 class FileReaderror(val #: File): ToError() 6 class DatabaseError(val source: DataSource): TOError() 7 8 object Runtimetrror : Error sealed class hosted with © by GitHub view raw Asealed class is abstract by itself, it cannot be instantiated directly and can have abstract members. Q16. What is significance of annotations : @JvmStatic, @JvmOverloads, and @JvmFiled in Kotlin? -> @JvmStatic: This annotation is used to tell the compiler that the method is a static method and can be used in Java code. -> @JvmOverloads: To use the default values passed as an argument in Kotlin code from the Java code. -> @JvmField: To acces getters and setters. the fields of a Kotlin class from Java code without using any Q17. What are infix functions? An infix function is used to call the function without using any bracket or parenthesis. You need to use the infix keyword to use the infix function. eg. 2 infix fun Int-add(b : Int) : Int = this + 2 3 val y = 10 add 20 // infix function call infix function hosted with © by GitHub view raw hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73parva as Kotin Interview Cheat Shest Two Months ago when i started appearing... |by Kapil Vij | ct, 2021 | Mecium Open in app e@ abject ASingleton kottn singleton hosted with © by GitHub view raw This is equivalent to below java code : public final class ASingleton ( public static final ASingleton INSTANCE; private asingleton() { INSTANCE = (ASingleton)this; static ¢ new ASingleton(); x ui) java singleton hosted with © by GitHub view raw Q19. What are advantages to when over switch in kotlin? It is more concise and powerful than a traditional switch. when can be used either as an expression or as a statement. hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73Kotin Interview Cheat Shest Two Months ago when i started appearing... |by Kapil Vij | ct, 2021 | Mecium Openinapp e parva as Q20. What are primary and secondary constructors in Kotlin? Primary Constructor is initialized in the class header, goes after the class name, using the constructor keyword. The parameters are optional in the primary constructor. The primary constructor cannot contain any code, the initialization code can be placed in a separate initializer block prefixed with the init keyword. Secondary Constructor — Kotlin may have one or more secondary constructors. Secondary constructors allow initialization of variables and allow to provide some logic hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73 19arias asa Kolin Interview Cheat Sheat. Two Months ago when i started appearing... [by Kapil Vi | Oct, 2021 | Macium openinaoe e Q21. What are Higher Order Functions? A higher-order function is a function that takes functions as parameters, or returns a function. hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73arias asa Kolin Interview Cheat Sheat. Two Months ago when i started appearing... [by Kapil Vi | Oct, 2021 | Macium openinaoe e That’s all folks. But Keep watching this space coz I will keep updating the same article References : Biggest References are actual Interviews with Product companies like Walmart, Byju’s, OyoRooms, Deutsche Telekom, Zee Entertainment, GoJek and many more. https://kotlinlang.org/docs/home.htm! Kotlin Interview Questions Android App Development Android hitps:ikapiv. medium. convkoln-intrview-cheat-shaet-c6267850ba73 89
You might also like
Kotlin Interview Questions and Answers
PDF
No ratings yet
Kotlin Interview Questions and Answers
9 pages
Cracking - iOS Interview - Questions Notes
PDF
No ratings yet
Cracking - iOS Interview - Questions Notes
12 pages
Kotlin Interview Questions
PDF
100% (1)
Kotlin Interview Questions
44 pages
Big O
PDF
No ratings yet
Big O
2 pages
Unit 1: Crazy Rides
PDF
100% (1)
Unit 1: Crazy Rides
11 pages
Kotlin
PDF
No ratings yet
Kotlin
18 pages
Kotlin Interview Questions
PDF
No ratings yet
Kotlin Interview Questions
8 pages
Android Interview
PDF
No ratings yet
Android Interview
20 pages
Android Interview Questions - Tutorialspoint
PDF
100% (1)
Android Interview Questions - Tutorialspoint
5 pages
Top 50 Android Interview Questions
PDF
No ratings yet
Top 50 Android Interview Questions
9 pages
Android Studio Unit Testing
PDF
No ratings yet
Android Studio Unit Testing
4 pages
Agile Presentation PDF
PDF
No ratings yet
Agile Presentation PDF
34 pages
Introduction To Programming Methodology
PDF
No ratings yet
Introduction To Programming Methodology
48 pages
An Intuitive Introduction To Data Structures
PDF
No ratings yet
An Intuitive Introduction To Data Structures
183 pages
Basic iOS Cheat Sheet For Android Developers v4 Jakub Chmiel
PDF
No ratings yet
Basic iOS Cheat Sheet For Android Developers v4 Jakub Chmiel
4 pages
100+ Java Interview Questions and Answers For 2020 - Edureka
PDF
No ratings yet
100+ Java Interview Questions and Answers For 2020 - Edureka
60 pages
Big O Notation
PDF
No ratings yet
Big O Notation
1 page
Android HttpURLConnection Example
PDF
No ratings yet
Android HttpURLConnection Example
11 pages
Jetpack Compose - ViewModels
PDF
No ratings yet
Jetpack Compose - ViewModels
2 pages
Android Interview Questions Cheat Sheet
PDF
No ratings yet
Android Interview Questions Cheat Sheet
26 pages
Hibernate Interview Questions and Answers: 1.what Is ORM ?
PDF
No ratings yet
Hibernate Interview Questions and Answers: 1.what Is ORM ?
34 pages
Big o
PDF
No ratings yet
Big o
2 pages
From Java To Kotlin PDF
PDF
No ratings yet
From Java To Kotlin PDF
9 pages
IOS Interview Questions (MCQ)
PDF
No ratings yet
IOS Interview Questions (MCQ)
2 pages
TOP 30 Android Developer Interview Questions
PDF
No ratings yet
TOP 30 Android Developer Interview Questions
26 pages
Senior Ios Developer 1590123379
PDF
No ratings yet
Senior Ios Developer 1590123379
2 pages
Get Combine Asynchronous Programming with Swift First Edition Scott Gardner PDF ebook with Full Chapters Now
PDF
100% (6)
Get Combine Asynchronous Programming with Swift First Edition Scott Gardner PDF ebook with Full Chapters Now
65 pages
BigO Omega Theta
PDF
No ratings yet
BigO Omega Theta
14 pages
ZT Rxjava Cheat Sheet
PDF
No ratings yet
ZT Rxjava Cheat Sheet
1 page
iOS Interview Questions Answers
PDF
No ratings yet
iOS Interview Questions Answers
29 pages
Kotlin Tutorial PDF
PDF
100% (1)
Kotlin Tutorial PDF
5 pages
Agile Terminology
PDF
No ratings yet
Agile Terminology
2 pages
Java Interview Questions and Answers
PDF
100% (15)
Java Interview Questions and Answers
32 pages
Android Application Development With Maven - Sample Chapter
PDF
No ratings yet
Android Application Development With Maven - Sample Chapter
32 pages
Intro To Kotlin
PDF
No ratings yet
Intro To Kotlin
21 pages
WWW Javatpoint Com Microservices Interview Questions
PDF
No ratings yet
WWW Javatpoint Com Microservices Interview Questions
12 pages
Kotlin Reference
PDF
No ratings yet
Kotlin Reference
1,158 pages
Short Questions For Mobile Applicaiton
PDF
No ratings yet
Short Questions For Mobile Applicaiton
8 pages
Online Android App Development Training Build Your Own Android Music Player App Duration: 6 Weeks - Certified Training
PDF
No ratings yet
Online Android App Development Training Build Your Own Android Music Player App Duration: 6 Weeks - Certified Training
3 pages
Java To Kotlin PDF
PDF
No ratings yet
Java To Kotlin PDF
19 pages
Android Interview Questions - Javatpoint1 PDF
PDF
No ratings yet
Android Interview Questions - Javatpoint1 PDF
8 pages
Hangman Turbo Cplusplus Source Code
PDF
No ratings yet
Hangman Turbo Cplusplus Source Code
3 pages
100 Core Java Interview Questions (2022) - Javatpoint
PDF
No ratings yet
100 Core Java Interview Questions (2022) - Javatpoint
47 pages
Effective+Dart +style+ +dart
PDF
No ratings yet
Effective+Dart +style+ +dart
11 pages
Data Structure & Algorithms
PDF
No ratings yet
Data Structure & Algorithms
41 pages
Danilo Cáceres Tanaka
PDF
No ratings yet
Danilo Cáceres Tanaka
1 page
Angular - The Complete Guide 2020 Edition
PDF
No ratings yet
Angular - The Complete Guide 2020 Edition
49 pages
Tran D. Principles, Policies, and Applications of Kotlin Programming 2023
PDF
100% (1)
Tran D. Principles, Policies, and Applications of Kotlin Programming 2023
476 pages
Core Java Notes
PDF
No ratings yet
Core Java Notes
210 pages
Data Structures Cheat Sheet
PDF
100% (1)
Data Structures Cheat Sheet
54 pages
Complexity Analysis of Algorithms
PDF
No ratings yet
Complexity Analysis of Algorithms
12 pages
Java Programming: II B.SC., Computer Science
PDF
No ratings yet
Java Programming: II B.SC., Computer Science
39 pages
Android Interview Questions, NKNKJN
PDF
No ratings yet
Android Interview Questions, NKNKJN
49 pages
Inter 1
PDF
No ratings yet
Inter 1
44 pages
5 Basic Kotlin Interview Questions With Answers
PDF
No ratings yet
5 Basic Kotlin Interview Questions With Answers
12 pages
Kotlin Basics
PDF
No ratings yet
Kotlin Basics
16 pages
Kotlin
PDF
No ratings yet
Kotlin
13 pages
TYBCA-501-02-AMC MCQ BANK
PDF
No ratings yet
TYBCA-501-02-AMC MCQ BANK
13 pages
Kotlin 100 Questiom
PDF
No ratings yet
Kotlin 100 Questiom
36 pages
Android Kotline Objective questions and answers
PDF
No ratings yet
Android Kotline Objective questions and answers
8 pages