Posts

Showing posts with the label android inteview question

🔍 What is Tight Coupling and Loose Coupling? (Android Developer Explanation)

✅  Tight Coupling Two classes/components are tightly coupled when they depend on each other directly. If one changes, the other must also change. It reduces flexibility and reusability. 📌 Example (Bad Practice – Tight Coupling) class UserRepository { fun getUser() = "Android Developer" } class UserViewModel { private val repository = UserRepository() // Direct object creation → TIGHT COUPLING fun printUser() { println(repository.getUser()) } } 🔴 Problems: UserViewModel cannot work without UserRepository Hard to unit test (cannot inject mock repo) If repository changes, viewmodel breaks Not reusable ✅ Loose Coupling Two classes are loosely coupled when they depend on abstractions (interfaces) instead of concrete classes. You can replace dependency without modifying main logic → more flexible. 📌 Example (Good Practice – Loose Coupling with DI) interface UserRepository { fun getUser(): String } class UserRepository...

Android Interview Questions 2022

JAVA Why String is mutable? String str1 = 10                 String str2 = 20         str1 == str2 is this true? What String Pool in java? Difference of StringBuffer vs String? Difference of StringBuilder vs StringBuffer? What is HashMap and purpose? Difference of HashMap vs HashTable? Difference of HashMap vs HashSet? What is array vs list? What is abstract class in java? What is collections in java? What is flatmap? What is array vs arraylist? What is Interface in Java? What is polymorphism ? What is singleton class? The following variable stored in which memory?                 String str = new String()  - memory?         String str = “test”;         String str1 = “test”; ...