Independent Developer Education Blog

Learn Android, React Native, JavaScript and real-world app development.

CodeChain Dev publishes practical tutorials, debugging guides, interview preparation, source-code explanations and mobile development notes for developers.

Topics Covered

  • Android, Kotlin and Java
  • React Native app development
  • JavaScript, APIs and debugging
  • SQL, Gradle and developer tools
Showing posts with label Interview. Show all posts
Showing posts with label Interview. Show all posts

Tuesday, October 13, 2020

Top Java Interview Questions and Answers for Developers in 2026

Java is still one of the most important programming languages for backend development, Android development, enterprise applications, fintech systems, and large-scale software platforms.

If you are preparing for a Java developer interview, you should understand the concepts clearly instead of memorizing definitions.

This guide covers important Java interview questions with simple explanations and practical examples.


1. What is Java?

Java is a high-level, object-oriented, platform-independent programming language. It follows the principle of Write Once, Run Anywhere because Java code is compiled into bytecode that runs on the JVM.


2. What is JVM, JRE, and JDK?

Term Meaning
JVM Java Virtual Machine runs Java bytecode.
JRE Java Runtime Environment contains JVM and libraries required to run Java programs.
JDK Java Development Kit contains JRE plus development tools like compiler.

3. What is the difference between Class and Object?

A class is a blueprint. An object is an instance of that class.


class User {
  String name;
}

User user = new User();
user.name = "Salil";

4. What are the main OOP concepts in Java?

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction

5. What is method overloading?

Method overloading means having multiple methods with the same name but different parameters.


class Calculator {
  int add(int a, int b) {
    return a + b;
  }

  double add(double a, double b) {
    return a + b;
  }
}

6. What is method overriding?

Method overriding happens when a child class provides its own implementation of a method already defined in the parent class.


class Animal {
  void sound() {
    System.out.println("Animal sound");
  }
}

class Dog extends Animal {
  @Override
  void sound() {
    System.out.println("Dog barks");
  }
}

7. What is the difference between overloading and overriding?

Overloading Overriding
Same method name with different parameters Same method name and parameters in child class
Compile-time polymorphism Runtime polymorphism
Can happen in same class Requires inheritance

8. What is inheritance?

Inheritance allows one class to acquire properties and methods of another class.


class Vehicle {
  void start() {
    System.out.println("Vehicle started");
  }
}

class Car extends Vehicle {
}

9. How can we stop inheritance in Java?

Use the final keyword with a class.


final class PaymentService {
}

10. What is encapsulation?

Encapsulation means wrapping data and methods together and restricting direct access using private variables and public methods.


class Account {
  private double balance;

  public double getBalance() {
    return balance;
  }
}

11. What is abstraction?

Abstraction hides implementation details and shows only essential behavior.


abstract class Shape {
  abstract void draw();
}

12. What is the difference between abstract class and interface?

Abstract Class Interface
Can have abstract and non-abstract methods Mainly defines contracts
Supports constructors Does not support constructors
Used for shared base behavior Used for capability-based design

13. What is the difference between == and equals()?

== compares object references. equals() compares object content when properly overridden.


String s1 = "Java";
String s2 = new String("Java");

System.out.println(s1 == s2);      // false
System.out.println(s1.equals(s2)); // true

14. What is String Pool?

String Pool is a special memory area where Java stores string literals to optimize memory usage.


String a = "Java";
String b = "Java";

System.out.println(a == b); // true

15. Difference between String, StringBuilder and StringBuffer

Type Use
String Immutable text
StringBuilder Mutable and faster, not thread-safe
StringBuffer Mutable and thread-safe

16. What is exception handling?

Exception handling allows Java programs to handle runtime errors gracefully using try, catch, finally, throw, and throws.


try {
  int result = 10 / 0;
} catch (ArithmeticException e) {
  System.out.println("Cannot divide by zero");
}

17. Checked vs Unchecked Exceptions

Checked Exception Unchecked Exception
Checked at compile time Occurs at runtime
Example: IOException Example: NullPointerException

18. What is HashMap?

HashMap stores data in key-value pairs. It allows fast lookup using hashing.


Map<String, Integer> map = new HashMap<>();
map.put("Java", 1);
System.out.println(map.get("Java"));

19. Difference between ArrayList and LinkedList

ArrayList LinkedList
Fast for searching Fast for insertion/deletion
Uses dynamic array Uses linked nodes

20. What is multithreading?

Multithreading allows multiple tasks to run concurrently in a Java program.


class MyThread extends Thread {
  public void run() {
    System.out.println("Thread running");
  }
}

21. What is synchronization?

Synchronization prevents multiple threads from accessing shared resources at the same time.


synchronized void updateBalance() {
  // critical section
}

22. What is garbage collection?

Garbage collection automatically removes unused objects from memory.

This helps prevent memory leaks and improves memory management.


23. What are Java 8 features?

  • Lambda expressions
  • Stream API
  • Functional interfaces
  • Default methods
  • Optional class

24. What is Stream API?

Stream API is used to process collections in a functional style.


List<String> names = Arrays.asList("Java", "Kotlin", "Android");

names.stream()
     .filter(name -> name.startsWith("J"))
     .forEach(System.out::println);

25. What is an immutable class?

An immutable class cannot be changed after object creation.


final class Employee {
  private final String name;

  Employee(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }
}

Java Interview Preparation Tips

  • Focus on OOP concepts first
  • Practice collections deeply
  • Understand JVM basics
  • Write small code examples
  • Revise exception handling
  • Practice multithreading questions
  • Prepare Java 8 features

FAQ

Is Java still useful in 2026?

Yes. Java is widely used in enterprise software, Android projects, fintech systems, backend services, and large-scale applications.

Which Java topic is most important for interviews?

OOP, collections, exception handling, multithreading, JVM, and Java 8 features are very important.

Is Java required for Android development?

Kotlin is now preferred for Android, but Java is still useful because many existing Android projects are written in Java.


About the Author

Salil Jha is a Full Stack and Mobile Developer with experience in Android, React Native, blockchain applications, crypto exchange platforms, SaaS products, and scalable backend systems.


Final Thoughts

Java interview preparation becomes easier when you understand concepts with practical examples.

Do not only memorize answers. Practice small programs, understand real use cases, and revise core Java fundamentals regularly.

CodeChain Dev — Build Modern Products. Solve Real Problems.

Monday, October 14, 2019

Top Android Interview Questions and Answers for Freshers and Experienced Developers

Android interviews commonly test both fundamental concepts and real-world development knowledge.

Whether you are a beginner Android developer or an experienced mobile engineer, understanding Android architecture, lifecycle, UI components, services, and application flow is essential.

In this guide, we will cover important Android interview questions with modernized explanations and updated Android development practices.


What Is Android?

Android is an open-source mobile operating system developed by Google.

It provides:

  • Operating System
  • Application Framework
  • Middleware
  • Development SDK
  • System Applications

Android applications run inside isolated application sandboxes for security and stability.


What Are the Advantages of Android?

  • Open-source platform
  • Large developer community
  • Powerful SDK
  • Supports Kotlin and Java
  • Wide device ecosystem
  • Google Play distribution
  • Rich APIs and libraries
  • Strong hardware integration

Describe Android Application Architecture

Android application architecture includes:

  • Activities
  • Fragments
  • Services
  • Broadcast Receivers
  • Content Providers
  • Intents
  • Resources
  • Notifications

What Is an Activity?

An Activity represents a single screen with a user interface.

Examples:

  • Login Screen
  • Home Screen
  • Settings Screen

Activities manage:

  • User interaction
  • Lifecycle events
  • Navigation
  • UI rendering

What Is an APK File?

APK stands for:


Android Package Kit

APK contains:

  • Compiled application code
  • Resources
  • Manifest file
  • Assets
  • DEX files

Android applications are distributed using APK files.


What Are the Activity Lifecycle Methods?

The Android Activity lifecycle consists of:

  1. onCreate()
  2. onStart()
  3. onResume()
  4. onPause()
  5. onStop()
  6. onRestart()
  7. onDestroy()

What Is an Intent?

Intent is a messaging mechanism used for communication between Android components.

Intents are used to:

  • Launch Activities
  • Start Services
  • Send Broadcasts
  • Open external applications

What Is an Explicit Intent?

Explicit Intent directly specifies the target component.


Intent intent =
        new Intent(
                MainActivity.this,
                HomeActivity.class
        );

What Is an Implicit Intent?

Implicit Intent does not specify the target component directly.

Android automatically finds a suitable application.


Intent intent =
        new Intent(
                Intent.ACTION_VIEW
        );

What Is AndroidManifest.xml?

AndroidManifest.xml is the central configuration file of an Android application.

It defines:

  • Activities
  • Permissions
  • Services
  • Broadcast Receivers
  • Application metadata

What Languages Are Used for Android Development?

Modern Android applications are primarily developed using:

  • Kotlin
  • Java

Google officially recommends Kotlin for Android development.


What Are DEX Files?

DEX stands for:


Dalvik Executable

DEX files contain compiled Android bytecode optimized for mobile devices.


What Is ADB?

ADB stands for:


Android Debug Bridge

ADB is a command-line tool used for:

  • Debugging
  • Installing APKs
  • Running shell commands
  • Viewing logs
  • Managing devices

What Is a Service?

A Service is an Android component used for background operations.

Examples:

  • Music playback
  • Location tracking
  • Background synchronization

Difference Between Service and Thread

Service Thread
Android component Concurrency mechanism
Lifecycle-aware Runs parallel tasks
Background functionality Worker execution

What Is a Content Provider?

Content Providers allow secure data sharing between Android applications.

Examples:

  • Contacts
  • Media files
  • Call logs

What Is a Toast Notification?

Toast is a lightweight popup message shown temporarily on screen.


Toast.makeText(
    this,
    "Login Successful",
    Toast.LENGTH_SHORT
).show();

What Is a Fragment?

Fragment is a reusable UI component hosted inside an Activity.

Fragments improve:

  • Modularity
  • Navigation
  • Large-screen support
  • Code reuse

What Is ViewGroup?

ViewGroup is a special View that contains other Views.

Examples:

  • LinearLayout
  • ConstraintLayout
  • FrameLayout
  • RelativeLayout

What Is ANR?

ANR stands for:


Application Not Responding

ANR occurs when the UI thread becomes blocked for too long.


How to Avoid ANR?

  • Avoid heavy work on main thread
  • Use Coroutines
  • Use WorkManager
  • Use background threads
  • Optimize network calls

What Is Dalvik Virtual Machine?

Dalvik Virtual Machine (DVM) was Android’s original runtime environment.

Modern Android versions now use:


ART (Android Runtime)

instead of Dalvik.


What Is Android Runtime (ART)?

ART is the modern Android runtime environment.

Benefits:

  • Better performance
  • Improved memory management
  • Faster execution
  • Ahead-of-time compilation

What Is RecyclerView?

RecyclerView is a modern and flexible ViewGroup used for displaying large data collections efficiently.

Benefits:

  • View recycling
  • Better performance
  • Animations support
  • Flexible layouts

What Is MVVM Architecture?

MVVM stands for:

  • Model
  • View
  • ViewModel

MVVM improves:

  • Code separation
  • Lifecycle awareness
  • Testing
  • Maintainability

What Is LiveData?

LiveData is a lifecycle-aware observable data holder class.

It automatically updates UI components when data changes.


What Is ViewModel?

ViewModel stores and manages UI-related data.

It survives configuration changes such as screen rotations.


What Is Room Database?

Room is an abstraction layer over SQLite.

Benefits:

  • Less boilerplate code
  • Compile-time SQL validation
  • Easy database management

What Is Jetpack Compose?

Jetpack Compose is Google’s modern declarative UI toolkit for Android.

It replaces traditional XML-based UI development.


What Is the Difference Between LinearLayout and ConstraintLayout?

LinearLayout ConstraintLayout
Simple row/column layout Flexible positioning system
Nested layouts required Flat hierarchy
Less efficient for complex UI Better performance

What Is the Difference Between Serializable and Parcelable?

Serializable Parcelable
Reflection-based Android optimized
Slower Faster
Easy implementation Better performance

Modern Android Recommendations

Modern Android applications commonly use:

  • Kotlin
  • Jetpack Compose
  • MVVM Architecture
  • Coroutines
  • Hilt Dependency Injection
  • Navigation Component
  • Retrofit
  • Room Database

Common Beginner Mistakes

1. Heavy Work on Main Thread

Always move network and database operations to background threads.


2. Ignoring Lifecycle

Lifecycle-aware components prevent memory leaks and crashes.


3. Using Deprecated APIs

Always prefer AndroidX and modern Jetpack libraries.


Conclusion

Android interviews test both theoretical understanding and practical Android development skills.

Developers should understand Android architecture, lifecycle management, UI systems, threading, networking, and modern Jetpack libraries.

Modern Android development now focuses heavily on Kotlin, Jetpack Compose, MVVM architecture, lifecycle awareness, and scalable application design.


About the Author

Salil Jha is a Full Stack and Mobile Developer specializing in Android, React Native, fintech systems, scalable SaaS platforms, and developer tooling products.

CodeChain Dev — Build Modern Products. Solve Real Problems.

Saturday, July 21, 2018

Android Interview Questions and Answers (Updated for Modern Android)

Preparing for an Android interview? This guide covers the most commonly asked Android interview questions with simple explanations and modern Android development concepts.


Broadcast Receiver Interview Questions

1. What is a Broadcast Receiver?

A Broadcast Receiver is an Android component used to listen for system-wide or application-wide events.

Examples:

  • Battery low
  • Wi-Fi state changed
  • Incoming SMS
  • Phone call received
  • Boot completed

2. How do you trigger a Broadcast Receiver?

Using an Intent and the sendBroadcast() method.


Intent intent = new Intent("com.example.MY_EVENT");
sendBroadcast(intent);

3. Types of Broadcast Receivers?

  • Static Receiver
  • Dynamic Receiver
  • Ordered Broadcast
  • Sticky Broadcast (deprecated)

4. What is the lifecycle method of Broadcast Receiver?


onReceive()

This method is automatically called when the receiver receives a matching broadcast event.


5. Why should heavy work not be done inside onReceive()?

Broadcast Receivers are short-lived components. Long operations inside onReceive() may cause ANR (Application Not Responding) issues.

Modern Android recommends:

  • WorkManager
  • Foreground Service
  • JobScheduler

SQLite Database Interview Questions

1. What is a database?

A database is an organized collection of structured data.


2. Which database is used in Android?

Android traditionally uses SQLite. Modern Android applications often use:

  • Room Database
  • SQLite
  • Realm
  • Firebase

3. Where is SQLite database stored?

Inside the application’s internal storage.


4. What is a Primary Key?

A Primary Key uniquely identifies each row in a table.

Properties:

  • Unique
  • Not Null

5. What is a Foreign Key?

A Foreign Key is used to create relationships between tables.


6. Difference Between DELETE and DROP

DELETE DROP
Deletes rows only Deletes entire table
DML operation DDL operation

7. Difference Between UPDATE and UPGRADE

UPDATE UPGRADE
Updates existing data Changes database schema
DML operation DDL operation

Activity and Fragment Interview Questions

1. How do you start an Activity?


Intent intent =
    new Intent(this, SecondActivity.class);

startActivity(intent);

2. How do you pass data to an Activity?


Intent intent =
    new Intent(this, SecondActivity.class);

intent.putExtra("name", "Salil");

startActivity(intent);

3. What is a Fragment?

A Fragment is a reusable UI component used inside Activities.

Fragments help create responsive UI designs for:

  • Mobile phones
  • Tablets
  • Foldable devices

4. How do you pass data to a Fragment?


Bundle bundle = new Bundle();

bundle.putString("name", "Android");

MyFragment fragment = new MyFragment();

fragment.setArguments(bundle);

5. Activity Lifecycle During Back Press

When user presses the Back button:


onPause()
onStop()
onDestroy()

6. Activity Lifecycle During Home Button Press


onPause()
onStop()

7. Activity Lifecycle During Screen Rotation


onPause()
onSaveInstanceState()
onStop()
onDestroy()

onCreate()
onStart()
onRestoreInstanceState()
onResume()

Important Activity Lifecycle Methods

onCreate()

  • First lifecycle method
  • Initialize views
  • Load UI
  • Setup dependencies

onPause()

  • Called when Activity partially loses focus
  • Save lightweight state
  • Pause animations or videos

onSaveInstanceState()

  • Used during configuration changes
  • Saves temporary UI state
  • Useful for screen rotations

Material Design Components Interview Questions

CoordinatorLayout

  • Advanced ViewGroup
  • Supports coordinated animations
  • Used with AppBarLayout and FAB

Toolbar

  • Modern replacement for ActionBar
  • Customizable
  • Can be placed anywhere in layout

RecyclerView

  • Modern replacement for ListView
  • Efficient and reusable
  • Uses ViewHolder pattern
  • Supports Grid and Staggered layouts

CardView

  • Provides elevation and rounded corners
  • Used for modern card-based UI

FloatingActionButton (FAB)

  • Represents primary action
  • Usually displayed bottom-right

Example: Compose button in Gmail


Snackbar

  • Modern alternative to Toast
  • Supports actions
  • Can be swiped away

Networking Interview Questions

1. What is HttpURLConnection?

A Java API used to establish network communication between Android application and server.


2. What is InputStream?

Used to read data coming from the server.


3. Difference Between InputStreamReader and BufferedReader

InputStreamReader BufferedReader
Reads character by character Reads efficiently in chunks
Slower Faster

REST API Interview Questions

What is REST API?

REST (Representational State Transfer) is a lightweight web service architecture used for communication between client and server.


REST vs SOAP

REST SOAP
Faster Slower
Uses JSON mostly Uses XML mostly
Lightweight Heavy protocol

Android Services Interview Questions

1. What is a Service?

A Service is an Android component used to perform background operations.


2. Types of Services?

  • Started Service
  • Bound Service
  • Foreground Service
  • IntentService (deprecated)

3. Service Lifecycle Methods


onCreate()
onStartCommand()
onBind()
onDestroy()

4. What is Foreground Service?

A Foreground Service performs important tasks visible to the user with a persistent notification.

Examples:

  • Music player
  • Navigation apps
  • Fitness tracking

Modern Android Development Topics

Important Topics for 2026 Interviews

  • Jetpack Compose
  • MVVM Architecture
  • Hilt Dependency Injection
  • Coroutines
  • Flow & StateFlow
  • Room Database
  • Retrofit
  • WorkManager
  • Navigation Component
  • Clean Architecture
  • Modularization
  • CI/CD

Conclusion

Android interviews today focus on both core Android concepts and modern Android architecture.

Understanding components like Activities, Fragments, Broadcast Receivers, Services, RecyclerView, Room, and networking concepts is essential for Android developer roles.

Modern Android development also expects knowledge of Kotlin, Jetpack Compose, MVVM, Coroutines, and scalable architecture patterns.


About the Author

Salil Jha is a Full Stack and Mobile Developer specializing in Android, React Native, scalable SaaS platforms, fintech systems, and modern web applications.

CodeChain Dev — Building scalable developer-first products.