├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Droid-Interview-Questions- 2 | Interview Questions on android Credit mindorks . 3 | 4 | 5 | ## A complete guide for learning Android Development 6 | 7 | ## Contents 8 | 9 | * [Core Android](#core-android) 10 | * [Android Libraries](#android-libraries) 11 | * [Android Architecture](#android-architecture) 12 | * [Android Design Problem](#android-design-problem) 13 | * [Android Unit Testing](#android-unit-testing) 14 | * [Android Tools And Technologies](#android-tools-and-technologies) 15 | * [Java and Kotlin](#java-and-kotlin) 16 | * [Data Structures And Algorithms](#data-structures-and-algorithms) 17 | * [Other Topics](#other-topics) 18 | 19 | ### Core Android 20 | 21 | #### Base 22 | 23 | * **Tell all the Android application components.** - [Learn from here](https://developer.android.com/guide/components/fundamentals.html#Components) 24 | 25 | * **What is the project structure of an Android Application?** - [Learn from here](https://developer.android.com/studio/projects) 26 | 27 | * **What is `Context`? How is it used?** - [Learn from here](https://blog.mindorks.com/understanding-context-in-android-application-330913e32514) 28 | 29 | * **What is `AndroidManifest.xml`?** - [Learn from here](https://developer.android.com/guide/topics/manifest/manifest-intro) 30 | 31 | * **What is `Application` class?** 32 | - The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created. 33 | 34 | #### Activity and Fragment 35 | 36 | * **What is `Activity` and its lifecycle?** - [Learn from here](https://www.youtube.com/watch?v=RiFui-i-s-o) 37 | 38 | * **What is the difference between onCreate() and onStart()** - [Learn from here](https://www.youtube.com/watch?v=RiFui-i-s-o) 39 | 40 | * **When only onDestroy is called for an activity without onPause() and onStop()?** - [Learn from here](https://www.youtube.com/watch?v=QSxcLnZ1-RU) 41 | 42 | * **Why do we need to call setContentView() in onCreate() of Activity class?** - [Learn from here](https://www.youtube.com/watch?v=zeYK8JdMOi8) 43 | 44 | * **What is onSavedInstanceState() and onRestoreInstanceState() in activity?** 45 | - onSavedInstanceState() - This method is used to store data before pausing the activity. 46 | - onRestoreInstanceState() - This method is used to recover the saved state of an activity when the activity is recreated after destruction. So, the onRestoreInstanceState() receive the bundle that contains the instance state information. 47 | 48 | * **What is `Fragment` and its lifecycle.** - [Learn from here](https://blog.mindorks.com/android-fragments-and-its-lifecycle) 49 | 50 | * **What are "launch modes"?** - [Learn from here](https://blog.mindorks.com/android-activity-launchmode-explained-cbc6cf996802) 51 | 52 | * **What is the difference between a `Fragment` and an `Activity`? Explain the relationship between the two.** - [Learn from here](https://stackoverflow.com/questions/10478233/why-fragments-and-when-to-use-fragments-instead-of-activities) 53 | 54 | * **When should you use a Fragment rather than an Activity?** 55 | - When you have some UI components to be used across various activities 56 | - When multiple view can be displayed side by side just like viewPager 57 | 58 | * **What is the difference between FragmentPagerAdapter vs FragmentStatePagerAdapter?** 59 | - FragmentPagerAdapter: Each fragment visited by the user will be stored in the memory but the view will be destroyed. When the page is revisited, then the view will be created not the instance of the fragment. 60 | - FragmentStatePagerAdapter: Here, the fragment instance will be destroyed when it is not visible to the user, except the saved state of the fragment. 61 | 62 | * **What is the difference between adding/replacing fragment in backstack?** - [Learn from here](https://stackoverflow.com/questions/24466302/basic-difference-between-add-and-replace-method-of-fragment/24466345) 63 | 64 | * **Why is it recommended to use only the default constructor to create a `Fragment`?** - [Learn from here](https://www.youtube.com/watch?v=9EdvcycKP9A) 65 | 66 | * **How would you communicate between two Fragments?** - [Learn from here](https://blog.mindorks.com/how-to-communicate-between-fragments) 67 | 68 | * **What is retained `Fragment`?** 69 | - By default, Fragments are destroyed and recreated along with their parent Activity’s when a configuration change occurs. Calling setRetainInstance(true) allows us to bypass this destroy-and-recreate cycle, signaling the system to retain the current instance of the fragment when the activity is recreated. 70 | 71 | * **What is the purpose of `addToBackStack()` while commiting fragment transaction?** 72 | - By calling addToBackStack(), the replace transaction is saved to the back stack so the user can reverse the transaction and bring back the previous fragment by pressing the Back button. For more [Learn from here](https://stackoverflow.com/questions/22984950/what-is-the-meaning-of-addtobackstack-with-null-parameter) 73 | 74 | #### Views and ViewGroups 75 | 76 | * **What is `View` in Android?** - [Learn from here](https://blog.mindorks.com/android-user-interface-view-components) 77 | 78 | * **Difference between `View.GONE` and `View.INVISIBLE`?** - [Learn from here](https://stackoverflow.com/questions/11556607/android-difference-between-invisible-and-gone) 79 | 80 | * **Can you a create custom view? How?** - [Learn from here](https://blog.mindorks.com/create-your-own-custom-view) 81 | 82 | * **What are ViewGroups and how they are different from the Views?** 83 | - View: View objects are the basic building blocks of User Interface(UI) elements in Android. View is a simple rectangle box which responds to the user’s actions. Examples are EditText, Button, CheckBox etc. View refers to the android.view.View class, which is the base class of all UI classes. 84 | - ViewGroup: ViewGroup is the invisible container. It holds View and ViewGroup. For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also. ViewGroup is the base class for Layouts. 85 | 86 | * **What is a Canvas?** - [Learn from here](https://blog.mindorks.com/understanding-canvas-api-in-android) 87 | 88 | * **What is a `SurfaceView`?** - [Learn from here](https://developer.android.com/reference/android/view/SurfaceView) 89 | 90 | * **Relative Layout vs Linear Layout.** - [Learn from here](https://blog.mindorks.com/android-layout-relative-linear-frame) 91 | 92 | * **Tell about Constraint Layout** - [Learn from here](https://blog.mindorks.com/using-constraint-layout-in-android-531e68019cd) 93 | 94 | * **Do you know what is the view tree? How can you optimize its depth?** - [Learn from here](https://developer.android.com/reference/android/view/ViewTreeObserver) 95 | 96 | * **How does the Touch Control and Events work in Android?** - [Learn from here](https://blog.mindorks.com/touch-control-and-events-in-android) and [here](https://www.youtube.com/watch?v=tKeYr7iV5xE) 97 | 98 | #### Displaying Lists of Content 99 | 100 | * **What is the difference between `ListView` and `RecyclerView`?** - [Learn from here](https://stackoverflow.com/questions/26728651/recyclerview-vs-listview) 101 | 102 | * **How does RecyclerView work internally?** - [Learn from here](https://blog.mindorks.com/how-does-recyclerview-work-internally) and [here](https://www.youtube.com/watch?v=60IYWdnHsZI) 103 | 104 | * **What is the ViewHolder pattern? Why should we use it?** - [Learn from here](https://stackoverflow.com/questions/21501316/what-is-the-benefit-of-viewholder-pattern-in-android) 105 | 106 | * **RecyclerView Optimization - Scrolling Performance Improvement** - [Learn from here](https://blog.mindorks.com/recyclerview-optimization) 107 | 108 | * **What is `SnapHelper`?** - [Learn from here](https://blog.mindorks.com/using-snaphelper-in-recyclerview-fc616b6833e8) 109 | 110 | #### Dialogs and Toasts 111 | 112 | * **What is `Dialog` in Android?** - [Learn from here](https://developer.android.com/guide/topics/ui/dialogs) 113 | 114 | * **What is `Toast` in Android?** - [Learn from here](https://developer.android.com/guide/topics/ui/notifiers/toasts) 115 | 116 | * **What the difference between `Dialog` and `Dialog Fragment`?** - [Learn from here](https://stackoverflow.com/questions/7977392/android-dialogfragment-vs-dialog) 117 | 118 | #### Intents and Broadcasting 119 | 120 | * **What is `Intent`?** - [Learn from here](https://blog.mindorks.com/what-are-intents-in-android) 121 | 122 | * **What is an Implicit `Intent`?** - [Learn from here](https://blog.mindorks.com/what-are-intents-in-android) 123 | 124 | * **What is an Explicit `Intent`?** - [Learn from here](https://blog.mindorks.com/what-are-intents-in-android) 125 | 126 | * **What is a `BroadcastReceiver`?** - [Learn from here](https://developer.android.com/guide/components/broadcasts) 127 | 128 | * **What is a `LocalBroadcastManager`?** - [Learn from here](https://blog.mindorks.com/using-localbroadcastmanager-in-android) 129 | 130 | * **What is the function of an `IntentFilter`?** - [Learn from here](https://developer.android.com/reference/android/content/IntentFilter) 131 | 132 | * **What is a Sticky `Intent`?** 133 | - Sticky Intents allows communication between a function and a service. sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). For example, if you take an intent for ACTION_BATTERY_CHANGED to get battery change events: When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was last Broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery. 134 | 135 | * **Describe how broadcasts and intents work to be able to pass messages around your app?** - [Learn from here](https://stackoverflow.com/questions/7276537/using-a-broadcast-intent-broadcast-receiver-to-send-messages-from-a-service-to-a) 136 | 137 | * **What is a `PendingIntent`?** 138 | - If you want someone to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent. 139 | 140 | * **What are the different types of Broadcasts?** - [Learn from here](https://developer.android.com/guide/components/broadcasts) 141 | 142 | #### Services 143 | 144 | * **What is `Service`?** - [Learn from here](https://developer.android.com/guide/components/services) 145 | 146 | * **`Service` vs `IntentService`.** - [Learn from here](https://blog.mindorks.com/service-vs-intentservice-in-android) 147 | 148 | * **What is a `JobScheduler`?** - [Learn from here](https://developer.android.com/reference/android/app/job/JobScheduler) 149 | 150 | #### Inter-process Communication 151 | 152 | * **How can two distinct Android apps interact?** - [Learn from here](https://developer.android.com/training/basics/intents) 153 | 154 | * **Is it possible to run an Android app in multiple processes? How?** - [Learn from here](https://stackoverflow.com/questions/6567768/how-can-an-android-application-have-more-than-one-process) 155 | 156 | * **What is AIDL? Enumerate the steps in creating a bounded service through AIDL.** - [Learn from here](https://developer.android.com/guide/components/aidl) 157 | 158 | * **What can you use for background processing in Android?** - [Learn from here](https://developer.android.com/guide/background) 159 | 160 | * **What is a `ContentProvider` and what is it typically used for?** - [Learn from here](https://developer.android.com/guide/topics/providers/content-provider-basics) and [here](https://developer.android.com/guide/topics/providers/content-providers) 161 | 162 | #### Long-running Operations 163 | 164 | * **How to run parallel tasks in Java or Android, and get callback when all complete?** - [Learn from here](https://www.youtube.com/watch?v=v0ZSnISeyKE) 165 | 166 | * **Why should you avoid to run non-ui code on the main thread?** - [Learn from here](https://developer.android.com/training/multiple-threads/communicate-ui) 167 | 168 | * **What is ANR? How can the ANR be prevented?** - [Learn from here](https://developer.android.com/topic/performance/vitals/anr.html) 169 | 170 | * **What is an `AsyncTask`(Deprecated in API level 30) ?** - [Learn from here](https://www.youtube.com/watch?v=ZZ-6nGbfVdA) 171 | 172 | * **What are the problems in AsyncTask?** - [Learn from here](https://www.youtube.com/watch?v=ZZ-6nGbfVdA) 173 | 174 | * **When would you use java thread instead of an AsyncTask?** - [Learn from here](https://stackoverflow.com/questions/18480206/asynctask-vs-thread-in-android) 175 | 176 | * **What is a `Loader`? (Deprecated)** - [Learn from here](https://developer.android.com/guide/components/loaders) 177 | 178 | * **What is the relationship between the life cycle of an `AsyncTask` and an `Activity`? What problems can this result in? How can these problems be avoided?** 179 | - An AsyncTask is not tied to the life cycle of the Activity that contains it. So, for example, if you start an AsyncTask inside an Activity and the user rotates the device, the Activity will be destroyed (and a new Activity instance will be created) but the AsyncTask will not die but instead goes on living until it completes. 180 | 181 | - Then, when the AsyncTask does complete, rather than updating the UI of the new Activity, it updates the former instance of the Activity (i.e., the one in which it was created but that is not displayed anymore!). This can lead to an Exception (of the type java.lang.IllegalArgumentException: View not attached to window manager if you use, for instance, findViewById to retrieve a view inside the Activity). 182 | 183 | - There’s also the potential for this to result in a memory leak since the AsyncTask maintains a reference to the Activity, which prevents the Activity from being garbage collected as long as the AsyncTask remains alive. 184 | 185 | - For these reasons, using AsyncTasks for long-running background tasks is generally a bad idea . Rather, for long-running background tasks, a different mechanism (such as a service) should be employed. 186 | 187 | - Note: AsyncTasks by default run on a single thread using a serial executor, meaning it has only 1 thread and each task runs one after the other. 188 | 189 | * **Explain `Looper`, `Handler` and `HandlerThread`.** - [Learn from here](https://blog.mindorks.com/android-core-looper-handler-and-handlerthread-bd54d69fe91a) and [from video](https://www.youtube.com/watch?v=rfLMwbOKLRk&list=PL6nth5sRD25hVezlyqlBO9dafKMc5fAU2) 190 | 191 | * **How does the threading work in Android?** - [Learn from here](https://www.youtube.com/watch?v=zfDYK-xB1Uo) 192 | 193 | * **Android Memory Leak and Garbage Collection** - [Learn from here](https://www.youtube.com/watch?v=zCSSFRRIreo) 194 | 195 | #### Working With Multimedia Content 196 | 197 | * **How do you handle bitmaps in Android as it takes too much memory?** - [Learn from here](https://developer.android.com/topic/performance/graphics/load-bitmap) and [here](https://developer.android.com/topic/performance/graphics/manage-memory) 198 | 199 | * **What is the difference between a regular `Bitmap` and a nine-patch image?** 200 | - In general, a Nine-patch image allows resizing that can be used as background or other image size requirements for the target device. The Nine-patch refers to the way you can resize the image: 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes. 201 | 202 | * **Tell about the `Bitmap` pool.** - [Learn from here](https://blog.mindorks.com/how-to-use-bitmap-pool-in-android-56c71a55533c) 203 | 204 | * **How to play sounds in Android?** - [Learn from here](https://blog.mindorks.com/using-mediaplayer-to-play-an-audio-file-in-android) 205 | 206 | * **How image compression is preformed?** - [Learn from here](https://blog.mindorks.com/understanding-image-compression-in-android) 207 | 208 | #### Data Saving 209 | 210 | * **How to persist data in an Android app?** - [Learn from here](https://blog.mindorks.com/android-shared-preferences-in-kotlin) 211 | 212 | * **What is ORM? How does it work?** - [Learn from here](https://www.youtube.com/watch?v=9OHzXUo3Ymk) 213 | 214 | * **How would you preserve `Activity` state during a screen rotation?** - [Learn from here](https://stackoverflow.com/questions/3915952/how-to-save-state-during-orientation-change-in-android-if-the-state-is-made-of-m) 215 | 216 | * **What are different ways to store data in your Android app?** - [Learn from here](https://blog.mindorks.com/understanding-storage-system-to-store-data-in-android) 217 | 218 | * **Explain Scoped Storage in Android.** - [Learn from here](https://blog.mindorks.com/understanding-the-scoped-storage-in-android) 219 | 220 | * **How to encrypt data in Android?** - [Learn from here](https://blog.mindorks.com/how-to-encrypt-data-safely-on-device-and-use-the-androidkeystore) 221 | 222 | * **What is commit() and apply() in SharedPreferences?** 223 | - commit() returns a boolean value of success or failure immediately by writing data synchronously. 224 | - apply() is asynchronous and it won't return any boolean response. If you have an apply() outstanding and you are performing commit(), then the commit() will be blocked until the apply() is not completed. 225 | 226 | #### Look and Feel 227 | 228 | * **What is a `Spannable`?** - [Learn from here](https://medium.com/androiddevelopers/underspanding-spans-1b91008b97e4) 229 | 230 | * **What is a `SpannableString`?** 231 | - A SpannableString has immutable text, but its span information is mutable. Use a SpannableString when your text doesn't need to be changed but the styling does. Spans are ranges over the text that include styling information like color, heighliting, italics, links, etc 232 | 233 | * **What are the best practices for using text in Android?** - [Learn from here](https://blog.mindorks.com/best-practices-for-using-text-in-android) 234 | 235 | * **How to implement Dark mode in any application?** - [Learn from here](https://blog.mindorks.com/implementing-dark-mode-theme-in-android) 236 | 237 | * **How to generate dynamic colors based in image?** - [Learn from here](https://blog.mindorks.com/color-palette-in-android) 238 | 239 | * **Explain about Density Independence Pixel** - [Learn from here](https://blog.mindorks.com/understanding-density-independent-pixel-sp-dp-dip-in-android) 240 | 241 | #### Memory Optimizations 242 | 243 | * **What is the `onTrimMemory()` method?** - [Learn from here](https://developer.android.com/topic/performance/memory) 244 | 245 | * **How does the OutOfMemory happens?** - [Learn from here](https://blog.mindorks.com/practical-guide-to-solve-out-of-memory-error-in-android-application) 246 | 247 | * **How do you find memory leaks in Android applications?** - [Learn from here](https://blog.mindorks.com/practical-guide-to-solve-out-of-memory-error-in-android-application) and [here](https://mindorks.com/blog/detecting-and-fixing-memory-leaks-in-android) 248 | 249 | #### Battery Life Optimizations 250 | 251 | * **How to reduce battery usage in an android application?** - [Learn from here](https://blog.mindorks.com/battery-optimization-for-android-apps-f4ef6170ff70) 252 | 253 | * **What is Doze? What about App Standby?** - [Learn from here](https://developer.android.com/training/monitoring-device-state/doze-standby) 254 | 255 | * **What is `overdraw`?** - [Learn from here](https://developer.android.com/topic/performance/rendering/overdraw.html) 256 | 257 | #### Supporting Different Screen Sizes 258 | 259 | * **How do you support different types of resolutions?** - [Learn from here](https://developer.android.com/training/multiscreen/screensizes) 260 | 261 | #### Permissions 262 | 263 | * **What are the different protection levels in permission?** - [Learn from here](https://blog.mindorks.com/what-are-the-different-protection-levels-in-android-permission) 264 | 265 | #### Native Programming 266 | 267 | * **What is the NDK and why is it useful?** - [Learn from here](https://www.youtube.com/watch?v=iljxHVt7Arc) and [here](https://blog.mindorks.com/getting-started-with-android-ndk-android-tutorial) and [here](https://www.youtube.com/watch?v=iljxHVt7Arc) 268 | 269 | * **What is renderscript?** - [Learn from here](https://blog.mindorks.com/comparing-android-ndk-and-renderscript-1a718c01f6fe) 270 | 271 | #### Android System Internal 272 | 273 | * **What is the Dalvik Virtual Machine?** - [Learn from here](https://blog.mindorks.com/what-are-the-differences-between-dalvik-and-art) 274 | 275 | * **What is the difference JVM, DVM and ART?** - [Learn from here](https://android.jlelse.eu/closer-look-at-android-runtime-dvm-vs-art-1dc5240c3924) 276 | 277 | * **What are the differences between Dalvik and ART?** - [Learn from here](https://blog.mindorks.com/what-are-the-differences-between-dalvik-and-art) 278 | 279 | * **What is DEX?** - [Learn from here](https://developer.android.com/reference/dalvik/system/DexFile) 280 | 281 | * **Can you manually call the Garbage collector?** - [Learn from here](https://stackoverflow.com/questions/15632734/can-we-call-the-garbage-collector-explicitly) 282 | 283 | #### Android Jetpack 284 | 285 | * **What is Android Jetpack and why to use this?** - [Learn from here](https://blog.mindorks.com/what-is-android-jetpack-and-why-should-we-use-it) 286 | 287 | * **What are Android Architecture Components?** - [Learn from here](https://blog.mindorks.com/what-are-android-architecture-components) 288 | 289 | * **What is LiveData in Android?** - [Learn from here](https://blog.mindorks.com/understanding-livedata-in-android) 290 | 291 | * **How LiveData is different from ObservableField?** - [Learn from here](https://blog.mindorks.com/livedata-vs-observable-in-android) 292 | 293 | * **What is the difference between setValue and postValue in LiveData?** - [Learn from here](https://blog.mindorks.com/livedata-setvalue-vs-postvalue-in-android) 294 | 295 | * **How to share ViewModel between Fragments in Android?** - [Learn from here](https://blog.mindorks.com/shared-viewmodel-in-android-shared-between-fragments) 296 | 297 | * **Explain Work Manager in Android.** - [Learn from here](https://blog.mindorks.com/integrating-work-manager-in-android) 298 | 299 | * **Use-cases of WorkManager in Android.** - [Learn from here](https://www.youtube.com/watch?v=4LTpYXFMnJw) 300 | 301 | * **How ViewModel work internally?** - [Learn from here](https://blog.mindorks.com/android-viewmodels-under-the-hood) 302 | 303 | #### Others 304 | 305 | * **Why Bundle class is used for data passing and why cannot we use simple Map data structure?** - [Learn from here](https://developer.android.com/guide/components/activities/parcelables-and-bundles) 306 | 307 | * **How do you troubleshoot a crashing application?** - [Learn from here](https://developer.android.com/topic/performance/vitals/crash) 308 | 309 | * **Explain Android notification system?** - [Learn from here](https://blog.mindorks.com/how-to-increase-push-notification-delivery-rate-in-android) 310 | 311 | * **What is the difference between Serializable and Parcelable? Which is the best approach in Android?** - [Learn from here](https://android.jlelse.eu/parcelable-vs-serializable-6a2556d51538) 312 | 313 | * **What is AAPT?** - [Learn from here](https://developer.android.com/studio/command-line/aapt2) 314 | 315 | * **What is the best way to update the screen periodically?** - [Learn from here](https://stackoverflow.com/questions/5452394/best-way-to-perform-an-action-periodically-while-an-app-is-running-handler) 316 | 317 | * **FlatBuffers vs JSON.** - [Learn from here](https://blog.mindorks.com/why-consider-flatbuffer-over-json-2e4aa8d4ed07) 318 | 319 | * **`HashMap`, `ArrayMap` and `SparseArray`** - [Learn from here](https://blog.mindorks.com/android-app-optimization-using-arraymap-and-sparsearray-f2b4e2e3dc47) 320 | 321 | * **What are Annotations?** - [Learn from here](https://blog.mindorks.com/creating-custom-annotations-in-android-a855c5b43ed9), [Link](https://blog.mindorks.com/improve-your-android-coding-through-annotations-26b3273c137a), [and from video](https://www.youtube.com/watch?v=LEb9if2HHSw) 322 | 323 | * **How to create custom Annotation?** - [Learn from here](https://blog.mindorks.com/creating-custom-annotations-in-android-a855c5b43ed9) and [here](https://www.youtube.com/watch?v=LEb9if2HHSw) 324 | 325 | * **How to handle multi-touch in android?** - [Learn from here](https://developer.android.com/training/gestures/multi) 326 | 327 | * **How to implement XML namespaces?** - [Learn from here](https://developer.android.com/reference/javax/xml/namespace/NamespaceContext) 328 | 329 | * **What is the support library? Why was it introduced?** - [Learn from here](https://developer.android.com/topic/libraries/support-library) 330 | 331 | * **What is Android Data Binding?** - [Learn from here](https://developer.android.com/topic/libraries/data-binding/index.html) 332 | 333 | * **How to check if Software keyboard is visible or not?** - [Learn from here](https://blog.mindorks.com/how-to-check-the-visibility-of-software-keyboard-in-android) 334 | 335 | * **How to take screenshot in Android programmatically?** - [Learn from here](https://blog.mindorks.com/how-to-programmatically-take-a-screenshot-on-android) 336 | 337 | ### Android Libraries 338 | 339 | * **Explain OkHttp Interceptor** - [Learn from here](https://blog.mindorks.com/okhttp-interceptor-making-the-most-of-it) 340 | 341 | * **OkHttp - HTTP Caching - How caching work in Android** - [Learn from here](https://www.youtube.com/watch?v=D6dQn6pUQD0) 342 | 343 | * **Tell me something about RxJava.** - [Learn from here](https://blog.mindorks.com/a-complete-guide-to-learn-rxjava-b55c0cea3631) 344 | 345 | * **How will you handle error in RxJava?** - [Learn from here](https://blog.mindorks.com/error-handling-in-rxjava) 346 | 347 | * **FlatMap Vs Map Operator** - [Learn from here](https://medium.com/mindorks/rxjava-operator-map-vs-flatmap-427c09678784) 348 | 349 | * **When to use `Create` operator and when to use `fromCallable` operator of RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-rxjava-create-and-fromcallable-operator) 350 | 351 | * **When to use `defer` operator of RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-rxjava-defer-operator) 352 | 353 | * **How are Timer, Delay, and Interval operators used in RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-rxjava-timer-delay-and-interval-operators) 354 | 355 | * **How to make two network calls in parallel using RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-rxjava-zip-operator-with-example) 356 | 357 | * **Tell the difference between Concat and Merge.** - [Learn from here](https://blog.mindorks.com/rxjava-operator-concat-vs-merge) 358 | 359 | * **Explain Subject in RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-rxjava-subject-publish-replay-behavior-and-async-subject-224d663d452f) 360 | 361 | * **What are the types of Observables in RxJava?** - [Learn from here](https://blog.mindorks.com/understanding-types-of-observables-in-rxjava-6c3a2d0819c8) 362 | 363 | * **How to implement EventBus with RxJava?** - [Learn from here](https://blog.mindorks.com/implementing-eventbus-with-rxjava-rxbus-e6c940a94bd8) 364 | 365 | * **How to implement search feature using RxJava in your application?** - [Learn from here](https://blog.mindorks.com/implement-search-using-rxjava-operators-c8882b64fe1d) 366 | 367 | * **How The Android Image Loading Library Glide and Fresco Works?** - [Learn from here](https://blog.mindorks.com/how-the-android-image-loading-library-glide-and-fresco-works-962bc9d1cc40) 368 | 369 | * **Difference between Schedulers.io() and Schedulers.computation() in RxJava.** 370 | 371 | * **Why do we use the Dependency Injection Framework like Dagger in Android?** - [Learn from here](https://blog.mindorks.com/why-do-we-use-the-dependency-injection-framework-in-android) 372 | 373 | * **How does the Dagger work?** - [Learn from here](https://blog.mindorks.com/android-annotation-processing-tutorial-part-1-a-practical-approach) and [here]((https://www.youtube.com/watch?v=Grzqz-B3NWU)) 374 | 375 | * **What is Component in Dagger?** - [Learn from here](https://www.youtube.com/watch?v=Grzqz-B3NWU) 376 | 377 | * **What is Module in Dagger?** - [Learn from here](https://www.youtube.com/watch?v=Grzqz-B3NWU) 378 | 379 | * **How does the custom scope work in Dagger?** 380 | 381 | * **When to call dispose and clear on CompositeDisposable in RxJava?** - [Learn from here](https://stackoverflow.com/questions/47057885/when-to-call-dispose-and-clear-on-compositedisposable) 382 | 383 | * **What is Multipart Request in Networking?** - [Learn from here](https://www.youtube.com/watch?v=p7SiNT0q1I8) 384 | 385 | * **What is Flow in Kotlin?** - [Learn from here](https://blog.mindorks.com/what-is-flow-in-kotlin-and-how-to-use-it-in-android-project) 386 | 387 | ### Android Architecture 388 | 389 | * **Describe the architecture of your last app.** 390 | 391 | * **Describe MVP.** - [Learn from here](https://mindorks.com/course/android-mvp-introduction) 392 | 393 | * **Describe MVVM.** - [Learn from here](https://blog.mindorks.com/mvvm-architecture-android-tutorial-for-beginners-step-by-step-guide) and [here](https://www.youtube.com/watch?v=HJMZNF-tG-4) 394 | 395 | * **MVC vs MVP vs MVVM architecture.** - [Learn from here](https://blog.mindorks.com/mvc-mvp-mvvm-architecture-in-android) 396 | 397 | * **What is presenter?** - [Learn from here](https://mindorks.com/course/android-mvp-introduction) 398 | 399 | * **What is model?** - [Learn from here](https://mindorks.com/course/android-mvp-introduction) 400 | 401 | * **Describe MVC.** - [Learn from here](https://blog.mindorks.com/mvc-mvp-mvvm-architecture-in-android) 402 | 403 | * **Describe MVI** - [Learn from here](https://github.com/MindorksOpenSource/MVI-Architecture-Android-Beginners) 404 | 405 | * **Describe the repository pattern** - [Learn from here](https://blog.mindorks.com/android-mvp-architecture-extension-with-interactors-and-repositories-bd4b51972339) 406 | 407 | * **What is controller?** - [Learn from here](https://blog.mindorks.com/mvc-mvp-mvvm-architecture-in-android) 408 | 409 | * **Tell something about clean code** - [Learn from here](https://blog.mindorks.com/every-programmer-should-read-this-book-6755dedec78d) 410 | 411 | ### Android Design Problem 412 | 413 | * **Design Uber App.** - [Learn from here](https://github.com/MindorksOpenSource/ridesharing-uber-lyft-app) 414 | 415 | * **Design Facebook App.** 416 | 417 | * **Design Facebook Near-By Friends App.** 418 | 419 | * **Design WhatsApp.** 420 | 421 | * **Design SnapChat.** 422 | 423 | * **Design problems based on location based app.** 424 | 425 | * **How to build offline-first app? Explain the architecture.** 426 | 427 | * **Design LRU Cache.** 428 | 429 | * **Design File Downloader** - [Learn from here](https://github.com/MindorksOpenSource/PRDownloader) 430 | 431 | * **Design an Image Loading Library** - [Learn from here](https://medium.com/@maheswaranapk/android-create-your-own-image-loading-library-in-kotlin-diy-bc7be9f286c5) 432 | 433 | * **HTTP Request vs HTTP Long-Polling vs WebSockets** - [Learn from here](https://www.youtube.com/watch?v=k56H0DHqu5Y) 434 | 435 | ### Android Unit Testing 436 | * **What is Espresso?** - [Learn from here](https://developer.android.com/training/testing/ui-testing/espresso-testing.html) 437 | 438 | * **What is Robolectric?** - [Learn from here](http://robolectric.org/) 439 | 440 | * **What are the disadvantages of using Robolectric?** - [Learn from here](https://stackoverflow.com/questions/18271474/robolectric-vs-android-test-framework) 441 | 442 | * **What is UI-Automator?** - [Learn from here](https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html) 443 | 444 | * **Explain unit test.** - [Learn from here](https://developer.android.com/training/testing/unit-testing/local-unit-tests) 445 | 446 | * **Explain instrumented test.** - [Learn from here](https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests) 447 | 448 | * **Have you done unit testing or automatic testing?** 449 | 450 | * **Why Mockito is used?** - [Learn from here](http://site.mockito.org/) 451 | 452 | * **Describe JUnit test.** - [Learn from here](https://en.wikipedia.org/wiki/JUnit) 453 | 454 | * **Describe code coverage.** - [Learn from here](https://blog.mindorks.com/generate-global-code-coverage-report-in-android-development-using-jacoco-plugin) 455 | 456 | ### Android Tools And Technologies 457 | 458 | * **What is ADB?** - [Learn from here](https://developer.android.com/studio/command-line/adb) 459 | 460 | * **What is DDMS and what can you do with it?** - [Learn from here](https://developer.android.com/studio/profile/monitor) 461 | 462 | * **What is the StrictMode?** - [Learn from here](https://blog.mindorks.com/use-strictmode-to-find-things-you-did-by-accident-in-android-development-4cf0e7c8d997) 463 | 464 | * **What is Lint? What is it used for?** - [Learn from here](https://blog.mindorks.com/what-is-lint-what-is-it-used-for) 465 | 466 | * **Git.** - [Learn from here](https://www.youtube.com/watch?v=D4h8Dbrjt4M&list=PL6nth5sRD25itbyNVUULAebzL-VLrLfkK) 467 | 468 | * **Android Development Useful Tools.** - [Learn from here](https://blog.mindorks.com/android-development-useful-tools-fd73283e82e3) 469 | 470 | * **Firebase.** - [Learn from here](https://firebase.google.com/) 471 | 472 | * **How to measure method execution time in Android?** - [Learn from here](https://blog.mindorks.com/measure-method-execution-time-in-android-debug-build) 473 | 474 | * **Can you access your database of SQLite Database for debugging?** - [Learn from here](https://blog.mindorks.com/how-to-access-sqlite-database-in-android-for-debugging) 475 | 476 | * **What are things that we need to take care while using Proguard?** - [Learn from here](https://blog.mindorks.com/things-to-care-while-using-proguard-in-android-application) 477 | 478 | * **What is Multidex in Android?** - [Learn from here](https://blog.mindorks.com/understanding-multidex-in-android) 479 | 480 | * **How to use Android Studio Memory Profiler?** - [Learn from here](https://www.youtube.com/watch?v=FxDa2td6Ej8) 481 | 482 | * **How to use Firebase realtime database in your app?** - [Learn from here](https://blog.mindorks.com/firebase-realtime-database-android-tutorial) 483 | 484 | * **What is Gradle?** - [Learn from here](https://blog.mindorks.com/gradle-for-android-developers-getting-the-most-of-it) 485 | 486 | * **APK Size Reduction.** - [Learn from here](https://blog.mindorks.com/how-to-reduce-apk-size-in-android-2f3713d2d662) and [here](https://blog.mindorks.com/using-r8-to-reduce-apk-size-in-android) 487 | 488 | * **How can you speed up the Gradle build?** - [Learn from here](https://blog.mindorks.com/speed-up-gradle-build-for-android-to-save-your-time) 489 | 490 | * **About gradle build system.** - [Learn from here](https://blog.mindorks.com/gradle-for-android-developers-getting-the-most-of-it) 491 | 492 | * **About multiple apk for android application.** - [Learn from here](https://mindorks.com/blog/how-to-create-multiple-apk-files-for-android-application) 493 | 494 | * **What is proguard used for?** - [Learn from here](https://blog.mindorks.com/applying-proguard-in-an-android-application) 495 | 496 | * **What is obfuscation? What is it used for? What about minification?** - [Learn from here](https://www.youtube.com/watch?v=yduedsaxfDw) 497 | 498 | * **How to change some parameters in an app without app update?** - [Learn from here](https://blog.mindorks.com/getting-started-with-firebase-remote-config-in-android) 499 | 500 | ### Java and Kotlin 501 | 502 | #### OOP 503 | 504 | * **Explain OOP Concepts.** 505 | - Object-Oriented Programming is a methodology of designing a program using classes, objects, 506 | [inheritance](https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)), 507 | [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)), 508 | [abstraction](https://en.wikipedia.org/wiki/Abstraction_(software_engineering)), and 509 | [encapsulation](https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)). 510 | 511 | * **What is the difference between a constructor and a method?** 512 | - The name of the constructor is same as that of the class name, whereas the name of the method can be anything. 513 | - There is no return type of a constructor. 514 | - When you make an object of a class, then the constructor of that class will be called automatically. 515 | But for methods, we need to call it explicitely. 516 | - Constructors can't be inherited but you can call the constructor of the parent class by calling `super()`. 517 | - Constructor and a method they both run a block of code but the difference is in calling them. 518 | - We can call method directly using their name. 519 | - Constructor Syntax - 520 | ```java 521 | public class SomeClassName{ 522 | SomeClassName(parameter_list){ 523 | ... 524 | } 525 | ... 526 | } 527 | ``` 528 | - Note: 529 | In the above syntax, the name of the constructor is the same as that of class 530 | and it has no return type. 531 | 532 | - Method Syntax 533 | ```java 534 | public class SomeClassName{ 535 | public void someMethodName(parameter_list){ 536 | ... 537 | } 538 | // call method 539 | someMethodName(parameter_list) 540 | } 541 | ``` 542 | * **Differences between abstract classes and interfaces?** 543 | - An abstract class, is a class that contains both concrete and abstract methods 544 | (methods without implementations). An abstract method must be implemented by the abstract class 545 | sub-classes. Abstract classes cannot be instantiated and need to be extended to be used. 546 | - An interface is like a blueprint/contract of a class (or it may be thought of as a class with methods, but without their implementation). It contains empty methods that 547 | represent, what all of its subclasses should have in common. The subclasses provide the 548 | implementation for each of these methods. Interfaces are implemented. 549 | 550 | * **What is the difference between iterator and enumeration in java?** 551 | - In Enumeration we don't have remove() method and we can only read and traverse through a collection. 552 | - Iterators can be applied to any collection. In Iterator, we can read and remove items from a collection. 553 | 554 | * **Do you agree we use composition over inheritance?** [Learn from here](https://www.journaldev.com/12086/composition-vs-inheritance) 555 | 556 | * **Difference between method overloading and overriding.** 557 |

558 | Overloading and Overriding 559 |

560 | - Overloading happens at compile-time while Overriding happens at runtime: The binding of overloaded method call to its definition happens at compile-time however binding of overridden method call to its definition happens at runtime. 561 | More info on static vs. dynamic binding: [StackOverflow](https://stackoverflow.com/questions/19017258/static-vs-dynamic-binding-in-java). 562 | - Static methods can be overloaded which means a class can have more than one static method of same name. Static methods cannot be overridden, even if you declare a same static method in child class it has nothing to do with the same method of parent class as overridden static methods are chosen by the reference class and not by the class of the object. 563 | 564 | So, for example: 565 | ```java 566 | public class Animal { 567 | public static void testClassMethod() { 568 | System.out.println("The static method in Animal"); 569 | } 570 | 571 | public void testInstanceMethod() { 572 | System.out.println("The instance method in Animal"); 573 | } 574 | } 575 | 576 | public class Cat extends Animal { 577 | public static void testClassMethod() { 578 | System.out.println("The static method in Cat"); 579 | } 580 | 581 | public void testInstanceMethod() { 582 | System.out.println("The instance method in Cat"); 583 | } 584 | 585 | public static void main(String[] args) { 586 | Cat myCat = new Cat(); 587 | myCat.testClassMethod(); 588 | Animal myAnimal = myCat; 589 | myAnimal.testClassMethod(); 590 | myAnimal.testInstanceMethod(); 591 | } 592 | } 593 | ``` 594 | Will output: 595 | ```java 596 | The static method in Cat // testClassMethod() is called from "Cat" reference 597 | 598 | The static method in Animal // testClassMethod() is called from "Animal" reference, 599 | // ignoring actual object inside it (Cat) 600 | 601 | The instance method in Cat // testInstanceMethod() is called from "Animal" reference, 602 | // but from "Cat" object underneath 603 | ``` 604 | 605 | The most basic difference is that overloading is being done in the same class while for overriding base and child classes are required. Overriding is all about giving a specific implementation to the inherited method of parent class. 606 | 607 | Static binding is being used for overloaded methods and dynamic binding is being used for overridden/overriding methods. 608 | Performance: Overloading gives better performance compared to overriding. The reason is that the binding of overridden methods is being done at runtime. 609 | 610 | Private and final methods can be overloaded but they cannot be overridden. It means a class can have more than one private/final methods of same name but a child class cannot override the private/final methods of their base class. 611 | 612 | Return type of method does not matter in case of method overloading, it can be same or different. However in case of method overriding the overriding method can have more specific return type (meaning if, for example, base method returns an instance of Number class, all overriding methods can return any class that is extended from Number, but not a class that is higher in the hierarchy, like, for example, Object is in this particular case). 613 | 614 | Argument list should be different while doing method overloading. Argument list should be same in method Overriding. 615 | It is also a good practice to annotate overridden methods with `@Override` to make the compiler be able to notify you if child is, indeed, overriding parent's class method during compile-time. 616 | 617 | * **What are the access modifiers you know? What does each one do?**
618 | - There are four access modifiers in Java language (from strictest to the most lenient): 619 | 1. `private` *variables*, *methods*, *constructors* or *inner classes* are only visible to its' containing class and its' methods. This modifier is most commonly used, for example, to allow variable access only through getters and setters or to hide underlying implementation of classes that should not be used by user and therefore maintain encapsulation. Singleton constructor is also marked `private` to avoid unwanted instantiation from outside. 620 | 2. `Default` (no keyword is used) this modifier can be applied to *classes*, *variables*, *constructors* and *methods* and allows access from classes and methods inside the same package. 621 | 3. `protected` can be used on *variables*, *methods* and *constructors* therefore allowing access only to subclasses and classes that are inside the same package as protected members' class. 622 | 4. `public` modifier is widely-used on *classes*, *variables*, *constructors* and *methods* to grant access from any class and method anywhere. It should not be used everywhere as it implies that data marked with `public` is not sensitive and can not be used to harm the program. 623 | 624 | * **Can an Interface implement another Interface?** 625 | - Yes, an interface can implement another interface (and more than one), but it needs to use `extends`, rather than `implements` keyword. And while you can not remove methods from parent interface, you can add new ones freely to your sub-interface. 626 | 627 | * **What is Polymorphism? What about Inheritance?** 628 | - Polymorphism in Java has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding). Method overloading is an example of static polymorphism, while method overriding is an example of dynamic polymorphism. 629 | 630 | An important example of polymorphism is how a parent class refers to a child class object. In fact, any object that satisfies more than one IS-A relationship is polymorphic in nature. 631 | 632 | For instance, let’s consider a class `Animal` and let `Cat` be a subclass of `Animal`. So, any cat IS animal. Here, Cat satisfies the IS-A relationship for its own type as well as its super class Animal. 633 | - Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another. With the use of inheritance the information is made manageable in a hierarchical order. 634 | 635 | The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class). 636 | 637 | Inheritance uses the keyword `extends` to inherit the properties of a class. Following is the syntax of extends keyword. 638 | ```java 639 | class Super { 640 | ..... 641 | ..... 642 | } 643 | class Sub extends Super { 644 | ..... 645 | ..... 646 | } 647 | ``` 648 | 649 | * **Multiple inheritance in Classes and Interfaces in java** [Learn from here](http://codeinventions.blogspot.in/2014/07/can-interface-extend-multiple.html) 650 | 651 | * **What are the design patterns?** [Learn from here](https://blog.mindorks.com/mastering-design-patterns-in-android-with-kotlin) 652 | - Creational patterns 653 | - Builder [Wikipedia](https://en.wikipedia.org/wiki/Builder_pattern?oldformat=true) 654 | - Factory [Wikipedia](https://en.wikipedia.org/wiki/Factory_method_pattern?oldformat=true) 655 | - Singleton [Wikipedia](https://en.wikipedia.org/wiki/Singleton_pattern) 656 | - Monostate [Wikipedia](http://wiki.c2.com/?MonostatePattern) 657 | - Fluent Interface Pattern [Wikipedia](https://martinfowler.com/bliki/FluentInterface.html) 658 | - Structural patterns 659 | - Adapter [Wikipedia](https://en.wikipedia.org/wiki/Adapter_pattern?oldformat=true) 660 | - Decorator [Wikipedia](https://en.wikipedia.org/wiki/Decorator_pattern?oldformat=true) 661 | - Facade [Wikipedia](https://en.wikipedia.org/wiki/Facade_pattern?oldformat=true) 662 | - Behavioural patterns 663 | - Chain of responsibility [Wikipedia](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern?oldformat=true) 664 | - Iterator [Wikipedia](https://en.wikipedia.org/wiki/Iterator_pattern?oldformat=true) 665 | - Strategy [Wikipedia](https://en.wikipedia.org/wiki/Strategy_pattern?oldformat=true) 666 | 667 | #### Collections and Generics 668 | 669 | * **Arrays Vs ArrayLists** - [Learn from here](https://stackoverflow.com/questions/32020000/what-is-the-difference-between-an-array-arraylist-and-a-list/32020072) and [here](https://www.youtube.com/watch?v=SMtSW3Zke_k) 670 | 671 | * **HashSet Vs TreeSet** - [Learn from here](https://stackoverflow.com/questions/25602382/java-hashset-vs-treeset-when-should-i-use-over-other) 672 | 673 | * **HashMap Vs Set** - [Learn from here](https://stackoverflow.com/questions/2773824/difference-between-hashset-and-hashmap) 674 | 675 | * **Stack Vs Queue** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/stack-and-queue) 676 | 677 | * **Explain Generics in Java?** 678 | - Generics were included in Java language to provide stronger type checks, by allowing the programmer to define, which classes can be used with other classes 679 | > In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types. ([Official Java Documentation](https://docs.oracle.com/javase/tutorial/java/generics/why.html)) 680 | 681 | - This means that, for example, you can define: 682 | ```java 683 | List list = new ArrayList<>(); 684 | ``` 685 | And let the compiler take care of noticing, if you put some object, of type other than `Integer` into this list and warn you. 686 | - It should be noted that standard class hierarchy *does not* apply to generic types. It means that `Integer` in `List` is not inherited from `` - it is actually inherited directly from ``. You can still put some constraints on what classes can be passed as a parameter into a generic by using [wildcards](https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html) like ``, `` or ``. 687 | - While generics are very useful, late inclusion into Java language has put some restraints on their implementation - backward compatibility required them to remain just "syntactic sugar" - they are erased ([type erasure](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html)) during compile-time and replaced with `object` class. 688 | 689 | * **What is Java PriorityQueue?** 690 | - In Priority Queue, each element is having some priority and all the elements are present in a queue. The operations are performed based on the priority. 691 | 692 | #### Objects and Primitives 693 | 694 | * **How is `String` class implemented? Why was it made immutable?** 695 | - There is no primitive variant of `String` class in Java language - all strings are just wrappers around underlying array of characters, which is declared `final`. This means that, once a `String` object is instantiated, it cannot be changed through normal tools of the language (Reflection still can mess things up horribly, because in Java no object is truly immutable). This is why `String` variables in classes are the first candidates to be used, when you want to override `hashCode()` and `equals()` of your class - you can be sure, that all their required contracts will be satisfied. 696 | > Note: The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation. ([Official Java Documentation](https://docs.oracle.com/javase/tutorial/java/data/strings.html)) 697 | 698 | This class is also unique in a sense, that, when you create an instance like this: 699 | ```java 700 | String helloWorld = "Hello, World!"; 701 | ``` 702 | `"Hello, World!"` is called a *literal* and compiler creates a `String` object with its' value. So 703 | ```java 704 | String capital = "Hello, World!".toUpperCase(); 705 | ``` 706 | is a valid statement, that, firstly, will create an object with literal value "Hello, World!" and then will create and return another object with value "HELLO, WORLD!" 707 | - `String` was made immutable to prevent malicious manipulation of data, when, for example, user login or other sensitive data is being send to a server. 708 | 709 | * **What does it means to say that a `String` is immutable?** 710 | - It means that once created, `String` object's `char[]` (its' containing value) is declared `final` and, therefore, it can not be changed during runtime. 711 | 712 | * **What is `String.intern()`? When and why should it be used?** 713 | - `String.intern()` is used to mange memory in Java code. It is used when we have duplicates value in different strings. When you call the `String.intern()`, then if in the String pool that string is present then the `equals()` method will return true and it will return that string only. 714 | 715 | * **Can you list 8 primitive types in java?** 716 | - `byte` 717 | - `short` 718 | - `int` 719 | - `long` 720 | - `float` 721 | - `double` 722 | - `char` 723 | - `String` 724 | - `boolean` 725 | 726 | * **What is the difference between an Integer and int?** 727 | - `int` is a primitive data type (with `boolean`, `byte`, `char`, `short`, `long`, `float` and `double`), while `Integer` (with `Boolean`, `Byte`, `Character`, `Short`,`Long`, `Float` and `Double`) is a [wrapper](https://docs.oracle.com/javase/tutorial/java/data/numberclasses.html) class that encapsulates primitive data type, while providing useful methods to perform different tasks with it. 728 | 729 | * **What is Autoboxing and Unboxing?** 730 | - Autoboxing and Unboxing is the process of automatic wrapping (putting in a box) and unwrapping (getting the value out) of primitive data types, that have "wrapper" classes. So `int` and `Integer` can (almost always) be used interchangeably in Java language, meaning a method `void giveMeInt(int i) { ... }` can take `int` as well as `Integer` as a parameter. 731 | 732 | * **Typecast in Java** 733 | - In Java, you can use casts to polymorph one class into another, compatible one. For example: 734 | ```java 735 | long i = 10l; 736 | int j = (int) i; 737 | long k = j; 738 | ``` 739 | Here we see, that, while narrowing (`long i` -> `int j`) requires an explicit cast to make sure the programmer realizes, that there may be some data or precision loss, widening (`int j` -> `long k`) does not require an explicit cast, because there can be no data loss (`long` can take larger numbers than `int` allows). 740 | 741 | * **Do objects get passed by reference or value in Java? Elaborate on that.** 742 | - In Java all primitives and objects are passed by value, meaning that their copy will be manipulated in the receiving method. But there is a caveat - when you pass an object reference into a method, a *copy of this reference* is made, so it still points to the same object. This means, that any changes that you make to the insides of this object are retained, when the method exits. 743 | ```java 744 | public class Pointer { 745 | 746 | int innerField; 747 | 748 | public Pointer(int a) { 749 | this.innerField = a; 750 | } 751 | } 752 | ``` 753 | ```java 754 | public class ValueAndReference { 755 | 756 | public static void main(String[] args) { 757 | 758 | Pointer a = new Pointer(0); 759 | int b = 1; 760 | 761 | print("Before:"); 762 | print("b = " + b); 763 | print("a.innerField = " + a.innerField); 764 | exampleMethod(a, b); 765 | print("After:"); 766 | print("b = " + b); 767 | print("a.innerField = " + a.innerField); 768 | } 769 | 770 | static void exampleMethod(Pointer a, int b) { 771 | a.innerField = 2; 772 | b = 10; 773 | } 774 | 775 | static void print(String text) { 776 | System.out.println(text); 777 | } 778 | } 779 | ``` 780 | Will output: 781 | ```java 782 | Before: 783 | 784 | b = 1 785 | 786 | a.innerField = 0 787 | 788 | After: 789 | 790 | b = 1 // a new local int variable was created and operated on, so "b" didn't change 791 | 792 | a.innerField = 2 // Pointer a got its' innerField variable changed 793 | // from 0 to 2, because method was operating on 794 | // the same reference to an instance 795 | ``` 796 | 797 | * **What is the difference between instantiation and initialization of an object?** - [Learn from here](https://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html) 798 | 799 | * **What the difference between local, instance and class variables?** 800 | - Local variables exist only in methods that created them, they are stored separately in their respected Thread Stack (for more information, see question about Java Memory Model) and cannot have their reference passed outside of the method scope. That also means that they cannot be assigned any access modifier or made `static` - because they only exist during enclosing method's execution and those modifiers just do not make sense, since no other outside method can get them anyway. 801 | - Instance variables are the ones, that are declared in classes and their value can be different from one instance of the class to another, but they always require that class' instance to exist. 802 | - Class variables are those, that are marked with `static` keyword in their class' body. They can only have one value across all instances of that class (changing it in one place will change it in their class and, therefore, in all instances) and can even be retrieved without that class' instance (if their access modifier allows it). 803 | 804 | #### Java Memory Model and Garbage Collector 805 | 806 | * **What is garbage collector? How does it work?** 807 | - All objects are allocated on the heap area managed by the JVM. 808 | As long as an object is being referenced, the JVM considers it alive. 809 | Once an object is no longer referenced and therefore is not reachable by the application code, 810 | the garbage collector removes it and reclaims the unused memory. 811 | 812 | * **What is Java Memory Model? What contracts does it guarantee? How are its' Heap and Stack organized?** - [Learn from here](http://tutorials.jenkov.com/java-concurrency/java-memory-model.html) 813 | 814 | * **What is memory leak and how does Java handle it?** - [Learn from here](https://developers.redhat.com/blog/2014/08/14/find-fix-memory-leaks-java-application/) 815 | 816 | * **What are strong, soft, weak and phantom references in Java?** - [Learn from here](https://dzone.com/articles/weak-soft-and-phantom-references-in-java-and-why-they-matter) 817 | 818 | #### Concurrency 819 | 820 | * **What does the keyword `synchronized` mean?** [Learn from here](https://stackoverflow.com/a/1085745/2621950) 821 | 822 | * **What is a `ThreadPoolExecutor`?** [Learn from here](https://blog.mindorks.com/threadpoolexecutor-in-android-8e9d22330ee3) 823 | 824 | * **What is `volatile` modifier?** [Learn from here](http://tutorials.jenkov.com/java-concurrency/volatile.html) 825 | 826 | * **The classes in the atomic package expose a common set of methods: `get`, `set,`, `lazyset`, `compareAndSet`, and `weakCompareAndSet`. Please describe them.** 827 | 828 | #### Exceptions 829 | 830 | * **How does the `try{}`, `catch{}`, `finally` works?** - [Learn from here](https://www.youtube.com/watch?v=Z_5e8MjRWnc&list=PL6nth5sRD25g_M_OgsMQgYIrESzzkGLME&index=13) 831 | 832 | * **What is the difference between a `Checked Exception` and an `Un-Checked Exception`?** - [Learn from here](https://www.w3schools.in/java-questions-answers/difference-between-checked-and-unchecked-exceptions-in-java/) 833 | 834 | #### Others 835 | 836 | * **What is serialization? How do you implement it?** 837 | - Serialization is the process of converting an object into a stream of bytes in order to store 838 | an object into memory, so that it can be recreated at a later time, while still keeping the 839 | object's original state and data. In Android you may use either the Serializable, Externalizable (implements Serializable) or Parcelable interfaces. 840 | - While Serializable is the easiest to implement, Externalizable may be used if you need to insert custom logic into the process of serialization (although it is almost never used nowadays as it is considered a relic from early versions of Java). But it is highly recommended to use Parcelable in Android instead, as Parcelable was created exclusively for Android and it performs about 10x faster than Serializable, because Serializable uses reflection, which is a slow process and tends to create a lot of temporary objects and it may cause garbage collection to occur more often. 841 | - To use Serializable all you have to do is implement the interface: 842 | 843 | ```java 844 | /** 845 | * Implementing the Serializable interface is all that is required 846 | */ 847 | public class User implements Serializable { 848 | 849 | private String name; 850 | private String email; 851 | 852 | public User() { 853 | } 854 | 855 | public String getName() { 856 | return name; 857 | } 858 | 859 | public void setName(final String name) { 860 | this.name = name; 861 | } 862 | 863 | public String getEmail() { 864 | return email; 865 | } 866 | 867 | public void setEmail(final String email) { 868 | this.email = email; 869 | } 870 | } 871 | ``` 872 | - Parcelable requires a bit more work: 873 | ```java 874 | public class User implements Parcelable { 875 | 876 | private String name; 877 | private String email; 878 | 879 | /** 880 | * Interface that must be implemented and provided as a public CREATOR field 881 | * that generates instances of your Parcelable class from a Parcel. 882 | */ 883 | public static final Creator CREATOR = new Creator() { 884 | 885 | /** 886 | * Creates a new USer object from the Parcel. This is the reason why 887 | * the constructor that takes a Parcel is needed. 888 | */ 889 | @Override 890 | public User createFromParcel(Parcel in) { 891 | return new User(in); 892 | } 893 | 894 | /** 895 | * Create a new array of the Parcelable class. 896 | * @return an array of the Parcelable class, 897 | * with every entry initialized to null. 898 | */ 899 | @Override 900 | public User[] newArray(int size) { 901 | return new User[size]; 902 | } 903 | }; 904 | 905 | public User() { 906 | } 907 | 908 | /** 909 | * Parcel overloaded constructor required for 910 | * Parcelable implementation used in the CREATOR 911 | */ 912 | private User(Parcel in) { 913 | name = in.readString(); 914 | email = in.readString(); 915 | } 916 | 917 | public String getName() { 918 | return name; 919 | } 920 | 921 | public void setName(final String name) { 922 | this.name = name; 923 | } 924 | 925 | public String getEmail() { 926 | return email; 927 | } 928 | 929 | public void setEmail(final String email) { 930 | this.email = email; 931 | } 932 | 933 | @Override 934 | public int describeContents() { 935 | return 0; 936 | } 937 | 938 | /** 939 | * This is where the parcel is performed. 940 | */ 941 | @Override 942 | public void writeToParcel(final Parcel parcel, final int i) { 943 | parcel.writeString(name); 944 | parcel.writeString(email); 945 | } 946 | } 947 | ``` 948 | Note: For a full explanation of the describeContents() method see [StackOverflow](https://stackoverflow.com/questions/4076946/parcelable-where-when-is-describecontents-used/4914799#4914799). 949 | In Android Studio, you can have all of the parcelable code auto generated for you, but like with everything else, it is always a good thing to try and understand everything that is happening. 950 | 951 | * **What is `transient` modifier?** [Learn from here](https://www.javatpoint.com/transient-keyword) 952 | 953 | * **What are anonymous classes?** [Learn from here](https://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html) 954 | 955 | * **What is the difference between using `==` and `.equals` on an object?** - [Learn from here](https://www.youtube.com/watch?v=aVjnX1MIHB8) 956 | 957 | * **What is the `hashCode()` and `equals()` used for?** - [Learn from here](https://www.geeksforgeeks.org/equals-hashcode-methods-java/) 958 | 959 | * **Why would you not call abstract method in constructor?** - [Learn from here](https://stackoverflow.com/questions/15327417/is-it-ok-to-call-abstract-method-from-constructor-in-java) 960 | 961 | * **When would you make an object value `final`?** 962 | 963 | * **What are these `final`, `finally` and `finalize` keywords?** 964 | - `final` is a keyword in the java language. It is used to apply restrictions on class, method and variable. Final class can't be inherited, final method can't be overridden and final variable value can't be changed. 965 | ```java 966 | class FinalExample { 967 | public static void main(String[] args) { 968 | final int x=100; 969 | x=200;//Compile Time Error because x is final 970 | } 971 | } 972 | ``` 973 | - `finally` is a code block and is used to place important code, it will be executed whether exception is handled or not. 974 | ```java 975 | class FinallyExample { 976 | public static void main(String[] args) { 977 | try { 978 | int x=300; 979 | }catch(Exception e) { 980 | System.out.println(e.getMessage()); } 981 | finally { 982 | System.out.println("finally block is executed"); 983 | } 984 | } 985 | } 986 | ``` 987 | - `Finalize` is a method used to perform clean up processing just before object is garbage collected. 988 | ```java 989 | class FinalizeExample { 990 | public void finalize() { 991 | System.out.println("finalize called"); 992 | } 993 | 994 | public static void main(String[] args) { 995 | FinalizeExample f1=new FinalizeExample(); 996 | FinalizeExample f2=new FinalizeExample(); 997 | f1=null; 998 | f2=null; 999 | System.gc(); 1000 | } 1001 | } 1002 | ``` 1003 | 1004 | * **What is the difference between "throw" and "throws" keyword in Java?** 1005 | - `throws` is just used to indicated which exception is to be thrown. But the `throw` keyword is used to throw some exception from any static block or any method. 1006 | 1007 | * **What does the `static` word mean in Java?** 1008 | - In case of `static` variable it means that this variable (its' value or the object it references) spans across all instances of enclosing class (changing it in one instance affects all others), while in case of `static` methods it means that these methods can be invoked without an instance of their enclosing class. It is useful, for example, when you create util classes that need not be instantiated every time you want to use them. 1009 | 1010 | * **Can a `static` method be overridden in Java?** 1011 | - While child class can override a static method with another static method with the same signature (return type can be down-casted), it is not truly overridden - it becomes "hidden", but both methods can still be accessed under right circumstances (see question about overloading/overriding above). 1012 | 1013 | * **When is a `static` block run?** 1014 | - Code inside static block is executed only once: the first time you make an object of that class or the first time you access a static member of that class (even if you never make an object of that class). 1015 | 1016 | * **What is reflection?** 1017 | - You can inspect classes, interfaces, fields, and method at runtime with the help of reflection and the best part is that you need not know the names of these classes, methods, etc. 1018 | 1019 | * **What is Dependency Injection?** [Learn from here](https://www.youtube.com/watch?v=Grzqz-B3NWU) 1020 | 1021 | * **How is a `StringBuilder` implemented to avoid the immutable string allocation problem?** - [Learn from here](https://stackoverflow.com/questions/54023816/how-is-a-stringbuilder-implemented-to-avoid-the-immutable-string-allocation-prob) 1022 | 1023 | * **Difference between `StringBuffer` and `StringBuilder`?** - [Learn from here](https://www.journaldev.com/538/string-vs-stringbuffer-vs-stringbuilder) 1024 | 1025 | * **What is the difference between fail-fast and fail-safe iterators in Java?** 1026 | - Fail-safe iterator will not throw any exception even if the collection is modified while iteration over it. But in Fail-safe iterator, it throws a ConcurrentModificationException when you try to modify the collection while using it. 1027 | 1028 | * **What is Java NIO?** - [Learn from here](https://en.wikipedia.org/wiki/Non-blocking_I/O_(Java)) 1029 | 1030 | * **Monitor and Synchronization** - [Learn from here](https://www.youtube.com/watch?v=oLTw1aJpSho) 1031 | 1032 | * **Tell some advantages of Kotlin.** - [Learn from here](https://www.youtube.com/watch?v=kRhivT-jKzY&t=16s) 1033 | 1034 | * **What is the difference between `val` and `var`?** - [Learn from here](https://stackoverflow.com/questions/44200075/val-and-var-in-kotlin) 1035 | 1036 | * **What is the difference between `const` and `val`?** - [Learn from here](https://blog.mindorks.com/what-is-the-difference-between-const-and-val) 1037 | 1038 | * **How to ensure `null` safety in Kotlin?** - [Learn from here](https://blog.mindorks.com/safecalls-vs-nullchecks-in-kotlin) 1039 | 1040 | * **When to use `lateint` keyword used in Kotlin?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-lateinit-vs-lazy) 1041 | 1042 | * **How to check if a `lateinit` variable has been initialized?** - [Learn from here](https://blog.mindorks.com/how-to-check-if-a-lateinit-variable-has-been-initialized) 1043 | 1044 | * **How to do lazy initialization of variables in Kotlin?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-lateinit-vs-lazy) and [here](https://www.youtube.com/watch?v=yEX9_PeNRy4) 1045 | 1046 | * **What are `companion objects` in Kotlin?** - [Learn from here](https://blog.mindorks.com/companion-object-in-kotlin) 1047 | 1048 | * **What are the visibility modifiers in Kotlin?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-visibility-modifiers-private-protected-internal-public) 1049 | 1050 | * **What is the equivalent of Java static methods in Kotlin?** - [Learn from here](https://blog.mindorks.com/what-is-the-equivalent-of-java-static-methods-in-kotlin) 1051 | 1052 | * **What is a data class in Kotlin?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-data-class) 1053 | 1054 | * **How to create a Singleton class in Kotlin?** - [Learn from here](https://blog.mindorks.com/how-to-create-a-singleton-class-in-kotlin) 1055 | 1056 | * **What is the difference between `open` and `public` in Kotlin?** - [Learn from here](https://blog.mindorks.com/understanding-open-keyword-in-kotlin) 1057 | 1058 | * **Explain the use-case of `let`, `run`, `with`, `also`, `apply` in Kotlin.** - [Learn from here](https://blog.mindorks.com/using-scoped-functions-in-kotlin-let-run-with-also-apply) and [here](https://www.youtube.com/watch?v=AiFBEH54Xpw) 1059 | 1060 | * **Difference between List and Array types in Kotlin** - [Learn from here](https://blog.mindorks.com/difference-between-list-and-array-types-in-kotlin) 1061 | 1062 | * **What are `Labels` in Kotlin?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-returns-jumps-labels) 1063 | 1064 | * **What is an `Init` block in Kotlin?** - [Learn from here](https://blog.mindorks.com/understanding-init-block-in-kotlin) 1065 | 1066 | * **Explain `pair` and `triple` in Kotlin.** - [Learn from here](https://blog.mindorks.com/pair-and-triple-in-kotlin) 1067 | 1068 | * **How to choose between `apply` and `with`?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-apply-vs-with) 1069 | 1070 | * **How to choose between `switch` with `when`?** - [Learn from here](https://blog.mindorks.com/replace-switch-with-when-in-kotlin) 1071 | 1072 | * **What are Coroutines in Kotlin?** - [Learn from here](https://blog.mindorks.com/mastering-kotlin-coroutines-in-android-step-by-step-guide) 1073 | 1074 | * **What is Coroutine Scope?** - [Learn from here](https://blog.mindorks.com/mastering-kotlin-coroutines-in-android-step-by-step-guide) 1075 | 1076 | * **What is Coroutine Context?** - [Learn from here](https://blog.mindorks.com/mastering-kotlin-coroutines-in-android-step-by-step-guide) 1077 | 1078 | * **Launch vs Async in Kotlin Coroutines** - [Learn from here](https://www.youtube.com/watch?v=nC30UiDv8Xc) 1079 | 1080 | * **What is inline function in Kotlin?** - [Learn from here](https://blog.mindorks.com/understanding-inline-noinline-and-crossinline-in-kotlin) 1081 | 1082 | * **When to use Kotlin sealed classes?** - [Learn from here](https://blog.mindorks.com/learn-kotlin-sealed-classes) 1083 | 1084 | * **Explain function literals with receiver in Kotlin?** - [Learn from here](https://blog.mindorks.com/function-literals-with-receiver-in-kotlin) 1085 | 1086 | * **Tell about Kotlin DSL.** - [Learn from here](https://blog.mindorks.com/mastering-kotlin-dsl-in-android-step-by-step-guide) 1087 | 1088 | * **What are higher-order functions in Kotlin?** - [Learn from here](https://blog.mindorks.com/understanding-higher-order-functions-and-lambdas-in-kotlin) 1089 | 1090 | * **What are Lambdas in Kotlin** - [Learn from here](https://blog.mindorks.com/understanding-higher-order-functions-and-lambdas-in-kotlin) 1091 | 1092 | * **Tell about the Collections in Kotlin** - [Learn from here](https://www.youtube.com/watch?v=XeRt2ZZ-jkA) 1093 | 1094 | ### Data Structures And Algorithms 1095 | 1096 | > The level of questions asked on the topic of Data Structures And Algorithms totally depends on the company for which you are applying. 1097 | 1098 | #### Whiteboard Interview Series - Data Structures and Algorithms on Youtube - [Check here](https://www.youtube.com/playlist?list=PLqOiaH9id5qt_lZl2bFi8q9RQoV1JJUpf) 1099 | 1100 | #### Tech Interview Preparation Kit - [Check here](https://afteracademy.com/tech-interview) 1101 | 1102 | #### Android Developer should know these Data Structures for Next Interview - [Check here](https://blog.mindorks.com/android-developer-should-know-these-data-structures-for-next-interview) 1103 | 1104 | * **Complexity Analysis** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/complexity-analysis) 1105 | - What is Input, Output, Correctness, Efficiency of Algorithms? 1106 | - What is Input Size and Running Time of Algorithms? 1107 | - Explain the Worst, Best, and Average case analysis of Algorithms. 1108 | - What is Big-O Notation with respect to Time and Space Complexity? 1109 | 1110 | * **Iteration and Two Pointer Approach** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/iteration-and-two-pointer-approach) 1111 | - Explain Initialization, Maintenance, and Termination used in iteration. 1112 | - Explain the use-case of Two Pointer approach 1113 | 1114 | * **Recursion and Divide & Conquer Approach** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/recursion-and-divide-and-conquer-approach) 1115 | - Explain Recursion with the help of an example and also draw the recursion call stack for the same. 1116 | - How will you analyse the recursive solution of some problem? 1117 | - Is there any difference between Recursion and Iteration? 1118 | - Explain the Divide and Conquer technique with the help of a real-world example. 1119 | 1120 | * **Arrays and Linked List** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/array-and-linked-list) 1121 | - What do you mean by Linear Data Structures? 1122 | - Explain the basic operations that can be performed on Arrays? Also, tell about Amortized analysis of array. 1123 | - What is a Linked List? Explain with an example by performing some operations on Linked List. 1124 | - What are the types of Linked List? 1125 | - Can you tell the difference between an Array and a Linked List? 1126 | 1127 | * **Stack and Queue** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/stack-and-queue) 1128 | - What is a Stack? Explain various operations that can be performed on a Stack. 1129 | - Can you implement Stack using an Array or using a Linked List? How? 1130 | - What is a Queue? Explain various operations that can be performed on a Queue. 1131 | - Can you implement Queue using an Array or using a Linked List? How? 1132 | - Is there any difference between a Stack and a Queue? 1133 | 1134 | * **Sorting Algorithms** - [Wikipedia](https://en.wikipedia.org/wiki/Sorting_algorithm?oldformat=true) 1135 | - Using the most efficient sorting algorithm (and correct data structures that implement it) is vital for any program, because data manipulation can be one of the most significant bottlenecks in case of performance and the main purpose of spending time, determining the best algorithm for the job, is to drastically improve said performance. The efficiency of an algorithm is measured in its' "Big O" ([StackOverflow](https://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation)) score. Really good algorithms perform important actions in O(n log n) or even O(log n) time and some of them can even perform certain actions in O(1) time (HashTable insertion, for example). But there is always a trade-off - if some algorithm is really good at adding a new element to a data structure, it is, most certainly, much worse at data access than some other algorithm. If you are proficient with math, you may notice that "Big O" notation has many similarities with "limits", and you would be right - it measures best, worst and average performances of an algorithm in question, by looking at its' function limit. It should be noted that, when we are speaking about O(1) - constant time - we are not saying that this algorithm performs an action in one operation, rather that it can perform this action with the same number of operations (roughly), regrardless of the amount of elements it has to take into account. Thankfully, a lot of "Big O" scores have been already calculated, so you don't have to guess, which algorithm or data structure will perform better in your project. ["Big O" cheat sheet](http://bigocheatsheet.com/) 1136 | - Bubble sort [Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort?oldformat=true) 1137 | - Bubble sort is one of the simplest sorting algorithms. It just compares neighbouring elements and if the one that precedes the other is smaller - it changes their places. So over one iteration over the data list, it is guaranteed that **at least** one element will be in its' correct place (the biggest/smallest one - depending on the direction of sorting). This is not a very efficient algorithm, as highly unordered arrays will require a lot of reordering (upto O(n^2)), but one of the advantages of this algorithm is its' space complexity - only two elements are compared at once and there is no need to allocate more memory, than those two will occupy. 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 |
Time ComplexitySpace Complexity
BestAverageWorstWorst
Ω(n)Θ(n^2)O(n^2)O(1)
1156 | - Selection sort [Wikipedia](https://www.wikiwand.com/en/Selection_sort) 1157 | - Firstly, selection sort assumes that the first element of the array to be sorted is the smallest, but to confirm this, it iterates over all other elements to check, and if it finds one, it gets defined as the smallest one. When the data ends, the element, that is currently found to be the smallest, is put in the beginning of the array. This sorting algorithm is quite straightforward, but still not that efficient on larger data sets, because to assign just one element to its' place, it needs to go over all data. 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 |
Time ComplexitySpace Complexity
BestAverageWorstWorst
Ω(n^2)Θ(n^2)O(n^2)O(1)
1176 | - Insertion sort [Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort?oldformat=true) 1177 | - Insertion sort is another example of an algorithm, that is not that difficult to implement, but is also not that efficient. To do its' job, it "grows" sorted portion of data, by "inserting" new encountered elements into already (innerly) sorted part of the array, which consists of previously encountered elements. This means that in best case (data is already sorted) it can confirm that its' job is done in Ω(n) operations, while, if all encountered elements are not in their required order as many as O(n^2) operations may be needed. 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 |
Time ComplexitySpace Complexity
BestAverageWorstWorst
Ω(n)Θ(n^2)O(n^2)O(1)
1196 | - Merge sort [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort?oldformat=true) 1197 | - This is a "divide and conquer" algorithm, meaning it recursively "divides" given array in to smaller parts (up to 1 element) and then sorts those parts, combining them with each other. This approach allows merge sort to achieve very high speed, while doubling required space, of course, but today memory space is more available than it was a couple of years ago, so this trade-off is considered acceptable. 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 |
Time ComplexitySpace Complexity
BestAverageWorstWorst
Ω(n log(n))Θ(n log(n))O(n log(n))O(n)
1216 | - Quicksort [Wikipedia](https://en.wikipedia.org/wiki/Quicksort?oldformat=true) 1217 | - Quicksort is considered, well, quite quick. When implemented correctly, it can be a significant number of times faster than its' main competitors. This algorithm is also of "divide and conquer" family and its' first step is to choose a "pivot" element (choosing it randomly, statistically, minimizes the chance to get the worst performance), then by comparing elements to this pivot, moving it closer and closer to its' final place. During this process, the elements that are bigger are moved to the right side of it and smaller elements to the left. After this is done, quicksort repeats this process for subarrays on each side of placed pivot (does first step recursively), until the array is sorted. 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 |
Time ComplexitySpace Complexity
BestAverageWorstWorst
Ω(n log(n))Θ(n log(n))O(n^2)O(n)
1236 | - There are, of course, more sorting algorithms and their modifications. We strongly recommend all readers to familiarize themselves with a couple more, because knowing algorithms is very important quality of a candidate, applying for a job and it shows understanding of what is happening "under the hood". 1237 | 1238 | * **Binary Tree** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/binary-tree) 1239 | - What are non-linear data structures? Give example. 1240 | - What is a Tree Data Structure? Explain the properties of tree with an example. 1241 | - How is Binary Tree different from a normal Tree? 1242 | - What is inorder, pre-order, post-order, and level-order traversal of a tree? Explain with an example. 1243 | - Can you find the inorder, pre-order, and post-order of a tree using Stack? How? 1244 | - Explain how searching, insertion, and deletion operations are performed on a Tree? 1245 | 1246 | * **Binary Search Tree** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/binary-search-tree) 1247 | - What is a Binary Search Tree? Explain its properties also. 1248 | - Explain how searching, insertion, and deletion operations are performed on a Binary Search Tree? 1249 | - How is Binary Search Tree different from Binary Tree? 1250 | 1251 | * **Heap and Priority Queue** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/heap-and-priority-queue) 1252 | - What is a Heap data structure and when it is used? 1253 | - Explain the operations that can be performed on a Heap. 1254 | - What is the difference between a min-heap and a max-heap? How to implement these two? 1255 | - What do you mean by Priority Queue? How to implement Priority Queue? 1256 | - What are the real-life applications of Priority Queue? 1257 | 1258 | * **Hash Table** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/hash-table) 1259 | - What do you mean by Direct Address Table? 1260 | - Can you perform search, insert, and delete in O(1)? How? 1261 | - Explain Hash Table and its properties. 1262 | - How to remove collision in Hash Table by Chaining and Open Addressing? 1263 | - What are the real-life applications of Hash Table? 1264 | 1265 | * **Dynamic Programming** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/dynamic-programming) 1266 | - What is Dynamic Programming and how to find if a problem can be solved using DP or not? 1267 | - What are two approaches of solving a Dynamic Programming problem? 1268 | - Explain Optimization and Combinatorial problems? 1269 | 1270 | * **Greedy Algorithms** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/greedy-algorithms) 1271 | - What do you mean by Greedy algorithms? How to find if a problem can be solved by Greedy approach or not? 1272 | - Is there any difference between Dynamic Programming and Greedy Algorithms? 1273 | 1274 | * **Backtracking** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/backtracking) 1275 | - What is Backtracking? 1276 | - How to find if a problem can be solved with Backtracking or not? 1277 | - What is Exhaustive Searching? 1278 | 1279 | * **Graph** - [Learn from here](https://afteracademy.com/tech-interview/ds-algo-concepts/graph) 1280 | - What is Graph and how to represent a Graph? 1281 | - Explain Depth First Search and Breadth First Search. 1282 | - How to represent a Graph? 1283 | - What are the real-life applications of Graph? 1284 | - What do you mean by Topological Sorting? 1285 | - Explain Dijkstra algorithm with an example. 1286 | - What is a Minimum Spanning Tree? 1287 | 1288 | ### Other Topics 1289 | 1290 | * **Describe how REST APIs work. What is REST?** - [Learn from here](https://www.youtube.com/watch?v=1wSEI6_SzMU) and [here](https://www.youtube.com/watch?v=HgXAoBomGcA) 1291 | 1292 | * **Describe SQLite.** - [Learn from here](https://blog.mindorks.com/android-sqlite-database-in-kotlin) and [here](https://www.youtube.com/watch?v=9OHzXUo3Ymk) 1293 | 1294 | * **Describe database.** - [Learn from here](https://afteracademy.com/blog/what-is-a-database-and-dbms) 1295 | 1296 | * **How do you control the application version update to specific number of users?** 1297 | 1298 | * **Can we identify users who have uninstalled our application?** 1299 | 1300 | * **Android Development Best Practices.** - [Learn from here](https://blog.mindorks.com/android-development-best-practices-83c94b027fd3) 1301 | 1302 | * **Android Code Style And Guidelines.** - [Learn from here](https://blog.mindorks.com/android-code-style-and-guidelines-d5f80453d5c7) 1303 | 1304 | * **Have you tried Kotlin?** - [Learn from here](https://blog.mindorks.com/why-you-must-try-kotlin-for-android-development-e14d00c8084b) 1305 | 1306 | * **What are the metrics that you should measure continuously while android application development?** - [Learn from here](https://blog.mindorks.com/android-app-performance-metrics-a1176334186e) 1307 | 1308 | * **What is Chrome Custom Tabs? How to display web content in your app?** - [Learn from here](https://blog.mindorks.com/android-browser-lets-launch-chrome-custom-tabs-with-kotlin) 1309 | 1310 | * **How to avoid API keys from check-in into VCS?** - [Learn from here](https://blog.mindorks.com/using-local-properties-file-to-avoid-api-keys-check-in-into-version-control-system) 1311 | 1312 | * **How does the Kotlin Multiplatform work?** - [Learn from here](https://blog.mindorks.com/how-does-the-kotlin-multiplatform-work) 1313 | 1314 | * **How to use Memory Heap Dumps data?** - [Learn from here](https://blog.mindorks.com/how-to-use-memory-heap-dumps-data) 1315 | 1316 | * **How to implement Dark Theme in your app?** - [Learn from here](https://blog.mindorks.com/build-material-and-dark-themes-apps-using-style-in-android) 1317 | 1318 | * **Have you tried Jetpack compose?** - [Learn from here](https://blog.mindorks.com/using-jetpack-compose-to-build-ui-in-android) 1319 | 1320 | * **How to secure the API keys used in an app?** - [Learn from here](https://blog.mindorks.com/securing-api-keys-using-android-ndk) 1321 | 1322 | * **How to convert check Java equivalent code of Kotlin?** - [Learn from here](https://blog.mindorks.com/how-to-convert-a-kotlin-source-file-to-a-java-source-file) 1323 | 1324 | * **Tell something about memory usage in Android.** - [Learn from here](https://blog.mindorks.com/understanding-memory-usage-in-android) 1325 | 1326 | * **What is Benchmarking?** - [Learn from here](https://blog.mindorks.com/improving-android-app-performance-with-benchmarking) 1327 | 1328 | * **Can you create transparent activity in Android?** - [Learn from here](https://blog.mindorks.com/how-to-create-a-transparent-activity-in-android) 1329 | 1330 | * **How to use Android Sensors?** - [Learn from here](https://blog.mindorks.com/using-android-sensors-android-tutorial) 1331 | 1332 | * **Explain Annotation processing.** - [Learn from here](https://blog.mindorks.com/android-annotation-processing-tutorial-part-1-a-practical-approach) 1333 | 1334 | * **How to increase the Notification delivery rate?** [Learn from here](https://blog.mindorks.com/how-to-increase-push-notification-delivery-rate-in-android) 1335 | 1336 | * **How does the notification system work?** [Learn from here](https://blog.mindorks.com/how-to-increase-push-notification-delivery-rate-in-android) 1337 | 1338 | * **How to show local Notification at an exact time?** [Learn from here](https://blog.mindorks.com/how-to-increase-push-notification-delivery-rate-in-android) 1339 | 1340 | ### Found this project useful :heart: 1341 | 1342 | * Support by clicking the :star: button on the upper right of this page. :v: 1343 | 1344 | [Check out MindOrks awesome open source projects here](https://mindorks.com/open-source-projects) 1345 | 1346 | ### License 1347 | ``` 1348 | Copyright (C) 2020 MINDORKS NEXTGEN PRIVATE LIMITED 1349 | 1350 | Licensed under the Apache License, Version 2.0 (the "License"); 1351 | you may not use this file except in compliance with the License. 1352 | You may obtain a copy of the License at 1353 | 1354 | http://www.apache.org/licenses/LICENSE-2.0 1355 | 1356 | Unless required by applicable law or agreed to in writing, software 1357 | distributed under the License is distributed on an "AS IS" BASIS, 1358 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1359 | See the License for the specific language governing permissions and 1360 | limitations under the License. 1361 | ``` 1362 | 1363 | ### Contributing to Android Interview Questions 1364 | Just make pull request. You are in! 1365 | --------------------------------------------------------------------------------