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)
90 views
Kotlin Interview Cheat Sheet
Uploaded by
cobesim739
AI-enhanced title
Copyright
© © All Rights Reserved
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)
90 views
Kotlin Interview Cheat Sheet
Uploaded by
cobesim739
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Kotlin interview cheat sheet For Later
Carousel Previous
Carousel Next
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
Node - Js Interview Questions
PDF
No ratings yet
Node - Js Interview Questions
41 pages
Android Interview Questions
PDF
No ratings yet
Android Interview Questions
24 pages
Kotlin Interview Questions
PDF
100% (1)
Kotlin Interview Questions
44 pages
Big O
PDF
No ratings yet
Big O
2 pages
Codility 2.0
PDF
No ratings yet
Codility 2.0
6 pages
Kotlin
PDF
No ratings yet
Kotlin
18 pages
Kotlin Interview Questions
PDF
No ratings yet
Kotlin Interview Questions
8 pages
Kotlin Reference
PDF
No ratings yet
Kotlin Reference
1,259 pages
Introduction To Programming Methodology
PDF
No ratings yet
Introduction To Programming Methodology
48 pages
Agile Presentation PDF
PDF
No ratings yet
Agile Presentation PDF
34 pages
Android Interview
PDF
No ratings yet
Android Interview
20 pages
Top 50 Android Interview Questions
PDF
No ratings yet
Top 50 Android Interview Questions
9 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
Android Interview Questions Cheat Sheet
PDF
No ratings yet
Android Interview Questions Cheat Sheet
26 pages
Android Interview Questions and Answers - Java Code Geeks
PDF
No ratings yet
Android Interview Questions and Answers - Java Code Geeks
5 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
BigO Omega Theta
PDF
No ratings yet
BigO Omega Theta
14 pages
An Intuitive Introduction To Data Structures
PDF
No ratings yet
An Intuitive Introduction To Data Structures
183 pages
Java To Kotlin PDF
PDF
No ratings yet
Java To Kotlin PDF
19 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
What Is Big O Notation
PDF
No ratings yet
What Is Big O Notation
6 pages
SQLite Database Connectivity in Android
PDF
No ratings yet
SQLite Database Connectivity in Android
7 pages
Jetpack Compose - ViewModels
PDF
No ratings yet
Jetpack Compose - ViewModels
2 pages
Android HttpURLConnection Example
PDF
No ratings yet
Android HttpURLConnection Example
11 pages
Top 50 OOPs Interview Questions and Answers
PDF
No ratings yet
Top 50 OOPs Interview Questions and Answers
6 pages
Unit 1 - OOP in Java Intro
PDF
No ratings yet
Unit 1 - OOP in Java Intro
24 pages
Kotlin Tutorial PDF
PDF
100% (1)
Kotlin Tutorial PDF
5 pages
Big o
PDF
No ratings yet
Big o
2 pages
Big O Notation
PDF
No ratings yet
Big O Notation
1 page
A Beginner's Guide To Big O Notation Rob Bell PDF
PDF
No ratings yet
A Beginner's Guide To Big O Notation Rob Bell PDF
6 pages
Agile and Test Estimation
PDF
No ratings yet
Agile and Test Estimation
5 pages
Hiredintech System Design The Twitter Problem Beta
PDF
100% (1)
Hiredintech System Design The Twitter Problem Beta
17 pages
01.1 Your First Android App
PDF
No ratings yet
01.1 Your First Android App
29 pages
Part 1 - Introduction
PDF
No ratings yet
Part 1 - Introduction
5 pages
Kotlin Reference
PDF
No ratings yet
Kotlin Reference
1,158 pages
From Java To Kotlin PDF
PDF
No ratings yet
From Java To Kotlin PDF
9 pages
Data Structures Cheat Sheet
PDF
100% (1)
Data Structures Cheat Sheet
54 pages
Java Interview Questions and Answers
PDF
100% (15)
Java Interview Questions and Answers
32 pages
51 Stringsorts
PDF
No ratings yet
51 Stringsorts
69 pages
Nailing 1Z0-808 Free Sample
PDF
No ratings yet
Nailing 1Z0-808 Free Sample
68 pages
Effective+Dart +style+ +dart
PDF
No ratings yet
Effective+Dart +style+ +dart
11 pages
Kotlin Tutorial
PDF
No ratings yet
Kotlin Tutorial
24 pages
Algorithms Assignment
PDF
No ratings yet
Algorithms Assignment
2 pages
How To Prepare For Your SDE Interview at Google
PDF
No ratings yet
How To Prepare For Your SDE Interview at Google
21 pages
Tricky Java Interview Questions: References
PDF
No ratings yet
Tricky Java Interview Questions: References
1 page
Hangman Turbo Cplusplus Source Code
PDF
No ratings yet
Hangman Turbo Cplusplus Source Code
3 pages
Effectiveness of Kotlin vs. Java in Android App Development Tasks
PDF
No ratings yet
Effectiveness of Kotlin vs. Java in Android App Development Tasks
45 pages
Angular - The Complete Guide 2020 Edition
PDF
No ratings yet
Angular - The Complete Guide 2020 Edition
49 pages
Big-O Notation
PDF
No ratings yet
Big-O Notation
8 pages
Regex Case Interview Guide
PDF
No ratings yet
Regex Case Interview Guide
10 pages
Mobile Application - Prelim
PDF
No ratings yet
Mobile Application - Prelim
4 pages
JetpackCompose Navigation
PDF
No ratings yet
JetpackCompose Navigation
58 pages
Why System Design
PDF
0% (1)
Why System Design
229 pages
Inter 1
PDF
No ratings yet
Inter 1
44 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
AADK_answers
PDF
100% (1)
AADK_answers
39 pages