Most Asked Java Coding Interview Questions
In this article i have added most common coding interview questions. If some one practice these he will do better in coding round In Shaa Allah

👋 Hey there! I’m Shohanur Rahman!
I’m a backend developer with over 5.5 years of experience in building scalable and efficient web applications. My work focuses on Java, Spring Boot, and microservices architecture, where I love designing robust API solutions and creating secure middleware for complex integrations.
💼 What I Do Backend Development: Expert in Spring Boot, Spring Cloud, and Spring WebFlux, I create high-performance microservices that drive seamless user experiences. Cloud & DevOps: AWS enthusiast, skilled in using EC2, S3, RDS, and Docker to design scalable and reliable cloud infrastructures. Digital Security: Passionate about securing applications with OAuth2, Keycloak, and digital signatures for data integrity and privacy. 🚀 Current Projects I’m currently working on API integrations with Spring Cloud Gateway and designing an e-invoicing middleware. My projects often involve asynchronous processing, digital signature implementations, and ensuring high standards of security.
📝 Why I Write I enjoy sharing what I’ve learned through blog posts, covering everything from backend design to API security and cloud best practices. Check out my posts if you’re into backend dev, cloud tech, or digital security!
String
How to reverse a String in java? Can you write a program without using any java inbuilt methods?
Input: String str = "abc"Output: "cba"Write a java program to check if two Strings are anagrams in java.
Input: String str1 = "RACE", str2 = "CARE"Output: "true"Write a program to check if String has all unique characters in java.
How to check if one String is the rotation of another String in java?
Find the length of a String without using any inbuilt method in java.
Write a program to print all permutations of String in java.
Array
Write a java Program to Find the Smallest and Largest Element in an Array.
Find the number occurring an odd number of times in an array
Find the minimum number of platforms required for the railway station
Given a sorted array and a number x, find the pair in an array whose sum is closest to x
Find all pairs of elements from an array whose sum is equal to a given number
Given an array of 0’s and 1’s in random order, you need to separate 0’s and 1’s in an array.
Count the number of occurrences (or frequency) of each element in a sorted array
-
int arr[] = {14, 12, 70, 15, 95, 65, 22, 30};Max Difference = 95-12 = 83 Search in a row-wise and column-wise sorted matrix.
Input: mat[4][4] = {{10, 20, 30, 40},{15, 25, 35, 45},{27, 29, 37, 48},{32, 33, 39, 50}} x = 29 Output: Found at (2, 1)Largest sum contiguous subarray.
Input: [-3, -4, 5, -1, 2, -4, 6, -1] Output: 8 Explanation: Subarray [5, -1, 2, -4, 6] is the max sum contiguous subarray with sum 8.Find the Contiguous Subarray with Sum to a Given Value in an array.
Input: arr[]={14, 12, 70, 15, 99, 65, 21, 90}; X =97.Sum found between index 1 to 3, Elements are 12, 17 and 15Min sum in contiguous subarray
Input: arr[] = {3, -4, 2, -3, -1, 7, -5}Output: -6-
Input: arr[] = {6, -3, -10, 0, 2}Output: 180 // The subarray is {6, -3, -10} Longest Common Prefix in an array of Strings in java.
Input: arr[] = {"javaworld","javabean","javatemp"};Output: "java"Find all subsets of a set (power set) in java.
Input: nums = [1,2,3]Output: [[3],[1],[2],[1,2,3],[1,3],[2,3],[1,2],[]]