└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Intermediate-Android-Questions 2 | Will be adding intermediate to advance level android/Kotlin/Java/OOPS questions with answers. 3 | 4 | Questions/Answers 5 | 6 | 7 | ### Q : what is a context or Why does Android require context ? (e.g. why even a toast requires a context?)** 8 | 9 | **A** : 10 | Based on Official documentations: 11 | 12 | "Context is an interface to global information about an application environment. 13 | This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, 14 | as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc." 15 | 16 | In toast, if you pass the resource directly, the toast class uses the context to get that resource. 17 | 18 | Make sure you use the right context at right place other wise it may lead to memory leaks 19 | 20 | For e.g. if you want to pass context to singleton class, pass application context to it rather than an activities. 21 | 22 | for more info on which one to use where- checkout https://blog.mindorks.com/understanding-context-in-android-application-330913e32514 23 | 24 | How using wrong context leads to memory leaks - check this article - https://medium.com/@banmarkovic/what-is-context-in-android-and-which-one-should-you-use-e1a8c6529652 25 | 26 | Also would highly recommend that you go through the official documentation as well. 27 | 28 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | 30 | ### Q : Can we define function inside a function in kotlin, if yes, how to call the inner function?** 31 | 32 | **A :** Yes. 33 | 34 | Kotlin supports nested functions but the scope of those nested functions is confined to the parent functions 35 | 36 | "Kotlin allows you to nest functions, one within another. We can declare and use a function within another function. 37 | When you declare a function within another function, the nested functions, visibility will stay exclusively within the 38 | parent function and cannot be accessed from outside." 39 | 40 | fun main(args: Array) { 41 | fun nested():String { 42 | return "String from nested function" 43 | } 44 | println("Nested Output: ${nested()}") 45 | } 46 | 47 | **Source** : https://www.oreilly.com/library/view/functional-kotlin/9781788476485/6725edd3-33dc-41d3-8b0d-fcab12de7898.xhtml 48 | 49 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 50 | 51 | ### Q : How is the main thread in android always alive? why doesn't it die after completing execution?** 52 | 53 | **A : ANSWER HERE (will add soon)** 54 | 55 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 56 | 57 | ### Q : In how many ways can you perform IPC in android?** 58 | 59 | **A : ANSWER HERE (will add soon)** 60 | 61 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 62 | 63 | ### Q : What is reflection?** 64 | 65 | **A : ANSWER HERE (will add soon)** 66 | 67 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 68 | 69 | ### Q : How and why should we use Android keystore?** 70 | 71 | **A : ANSWER HERE (will add soon)** 72 | 73 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 74 | 75 | ### Q : Why network calls consume battery?** 76 | 77 | **A : ANSWER HERE (will add soon)** 78 | 79 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 80 | 81 | **Q : Why data class can not be abstract, open, sealed, or inner?** 82 | 83 | **A : ANSWER HERE (will add soon)** 84 | 85 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 86 | 87 | **Q : why we can not add a var/val property in a secondary constructor** 88 | 89 | **A : ANSWER HERE (will add soon)** 90 | 91 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 92 | 93 | **Q : how using the "throws"(exception) keyword makes the code robust** 94 | 95 | **A : ANSWER HERE (will add soon)** 96 | 97 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 98 | 99 | **Q : How to convert list to Map** 100 | 101 | **A : ANSWER HERE (will add soon)** 102 | 103 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 104 | 105 | **Q : what is "race condition" in multi threading** 106 | 107 | **A : ANSWER HERE (will add soon)** 108 | 109 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 110 | 111 | **Q : what is a "backing field" in Kotlin** 112 | 113 | **A : ANSWER HERE (will add soon)** 114 | 115 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 116 | 117 | **Q : what is Concurrency Design pattern** 118 | 119 | **A : ANSWER HERE (will add soon)** 120 | 121 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 122 | 123 | **Q : what is Blocking Queue** 124 | 125 | **A : ANSWER HERE (will add soon)** 126 | 127 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 128 | 129 | **Q : Flow vs callBackflow vs channels** 130 | 131 | **A : ANSWER HERE (will add soon)** 132 | 133 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 134 | 135 | **Q : Loosely coupled vs tightly coupled code android** 136 | 137 | **A : ANSWER HERE (will add soon)** 138 | 139 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 140 | 141 | **Q : What is young generation memory** 142 | 143 | **A : ANSWER HERE (will add soon)** 144 | 145 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 146 | 147 | **Q : Threads,Handler,looper,handler thread and it's interaction with UI** 148 | 149 | **A : ANSWER HERE (will add soon)** 150 | 151 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 152 | 153 | **Q : ART vs DVM** 154 | 155 | **A : ANSWER HERE (will add soon)** 156 | 157 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 158 | 159 | **Q : How to make multiple api calls and then wait for result from all of them and then update the ui?** 160 | 161 | **A : ANSWER HERE (will add soon)** 162 | 163 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 164 | 165 | **Q : How to stop/discard/cancel api calls?** 166 | 167 | **A : ANSWER HERE (will add soon)** 168 | 169 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 170 | 171 | **Q : Difference between internal storage and external storage** 172 | 173 | **A : ANSWER HERE (will add soon)** 174 | 175 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 176 | 177 | **Q : What is iterator and what is iterator design pattern?** 178 | 179 | **A : ANSWER HERE (will add soon)** 180 | 181 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 182 | 183 | **Q : What is Proxy design pattern?** 184 | 185 | **A : ANSWER HERE (will add soon)** 186 | 187 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 188 | **Q : What is iterator and what is iterator design pattern?** 189 | 190 | **A : ANSWER HERE (will add soon)** 191 | 192 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 193 | 194 | **Q : What are class loaders?** 195 | 196 | **A : ANSWER HERE (will add soon)** 197 | 198 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 199 | 200 | **Q : What are weak references?** 201 | 202 | **A : ANSWER HERE (will add soon)** 203 | 204 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 205 | 206 | **Q : What is process death?** 207 | 208 | **A : ANSWER HERE (will add soon)** 209 | 210 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 211 | 212 | **Q : What is DSL (Domain specific language?** 213 | 214 | **A : ANSWER HERE (will add soon)** 215 | 216 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 217 | 218 | **Q : What is a value class in kotlin?** 219 | 220 | **A : ANSWER HERE (will add soon)** 221 | 222 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 223 | 224 | **Q : Changes introduced over various api levels android?** 225 | 226 | **A** : https://developer.android.com/studio/releases/platforms 227 | 228 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | --------------------------------------------------------------------------------