During interview it does not matter whatever framework you know, the initial stage of interviews is only based on the programming sense, coding skills and capability of problem solving.To test these, all the interviewers start interview from sample programming problems and most of these programming problems are from core java concepts.Here, in this article I have tried to put some initial level of java programming questions to get through the interview process.Keep an eye on this post as I will be regularly adding and updating more and more questions.

Write a Java program to find LCM of a given two numbers.LCM stands for Lowest Common Multiple. LCM of a two given number a and b is the smallest positive integer that is divisible by both a and b.For example the LCM of 4 and 6 is 12. Following is the java program to find LCM using while and for loop.... Read more ➤

Two words are said to be anagrams, if both the words contain same set of characters with all original letters exactly once. For example, the word **program** can be re-arranged as grampor and these both words form an anagram. Following is a java program to check if a string is anagram or not. There are two ways for this test - One is using equals() method provided in Arrays class and another by comparing each character of he words.... Read more ➤

A matrix is a rectangular array of numbers or expressions arranged in rows and columns.Below is the java program to add two 2D matrices.We can change the dimension variables accordingly for 3D and 4D matrix.... Read more ➤

Binary search is one of the famous and fundamental algorithm in computer science which solves a large number of problems in developing applications and APIs. It uses divide and conquer approach to find out the element.Here, we will be writing a sample program in java that implements binary search.The given array is a sorted array of n elements and we have to search the position a given element inside the array.... Read more ➤

Write a program to find factorial of a given number is a common java program asked in any interview to freshers.The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example factorial of 4 is 4*3*2 = 24.There are 2 ways to find a factorial of a given number - One by using for loop and the other using recursion.Following java program uses for loop to find factorial of a given number.... Read more ➤

Write a java program to reverse a given string using recursion without using any predefined function.This program checks the understanding of recursion in programming language and also checks the programming sense.Here, the method reverseString() is called recursively to revrse a given string.Following is the complete program.... Read more ➤

Write a java program to find all the permutations of any given string.Permutation is the each of several possible ways in which a set or number of things can be ordered or arranged.Order matters in case of Permutation.For example, the permutation of ab will be ab and ba.Following is the java program to find permutation of a given string.... Read more ➤

Write a java program to reverse a given number by using only numeric operators.Suppose, if you are given an input of 4567 then the output should be 7654.In the program below, we have only used the modulus or remainder and / operator.Following is the complete program.... Read more ➤

Write a java program to find the sum of all the prime numbers less than a given natural number N. The main purpose of this interview question is to check the programming sense and capabilities to check how good you are to convert existing logic into code. The question is mostly asked to freshers.The only main logic in this program is to find the prime numbers.Prime number is a number that is greater than 1 and divided by 1 or itself.For reminder, 2 is also a prime number.... Read more ➤

In java interview, this program can be asked in a multiple ways such as write program to find max repeated words or duplicate words or the count of each duplicate words.Whatever the question, the main programming concept is the same to count the occurrence of each word in a .txt file. To solve this programmatically, we can use Map implementation in Java that does not allow any duplicate key and at the end of iteration we can find out the count.Following is the complete program.Here, we are using java 8 Lambda operator during sorting.... Read more ➤

In many java interviews especially for freshers, it is asked to write program to find max two numbers from a given array.This kind of program is good to check the programming sense as this program does not use any inbuilt java sorting functions or predefined data structures or collections.It simply uses java iterations and programming sense to swap in between the numbers and find the solution.Following is the implementation.... Read more ➤

This java interview program is about finding lines with max character from a file in descending order.In this case, we will be using buffered reader to read a file and use java provided data structure TreeSet to hold the line and it's character length as it automatically maintains ascending order.Following is the program to find two lines with max characters in descending order.... Read more ➤

In the java interview, you will be asked to find the middle index or position of a given array where sum of numbers preceding the index is equals to sum of numbers succeeding the index.There are two ways to solve this problem.One is to use 2 for loops - one starting from the last index to the middle index and another starting from start index to middle index. Another way to solve it by using while loop - the while loop should stop when the start index crosses the end index. Following is the program to achieve this using while loop.... Read more ➤

While dealing with string, many of the time it is required to find or remove duplicate character from a string.Following is the java program to find duplicate or repeated characters from a given string.The program also results the count of the duplicate characters.... Read more ➤

Java program to find distinct words from file is a very common question in java interview.In the following program, we will be using BufferedReader to read a file and then retain distinct words from it. To achieve this, we will be using Set to store all the words from a file and since, set dos not allow duplicates, we can easily find the distinct words.Following is the complete java program for this.... Read more ➤

Fibonacci numbers are the numbers in which each number is the sum of the two preceding numbers.For example 1, 1, 2, 3, 5, 8, 13, 21, 34, ...The first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence.In most of the java interview, itapos;s a common programming question to check a given number is fibonacci number or not.... Read more ➤

Armstrong Number is a number that is the sum of its own digits each raised to the power of the number of digits.For example 371 is an Armstrong number as 3^3+7^3+1^3 = 371.It is also sometimes called as narcissistic number or pluperfect digital invariant (PPDI). Following is the java program to test if a given number is an armstrong number or not.... Read more ➤

**Suggest more topics in suggestion section or write your own article and share with your colleagues.**

©2017, DevGlan. All Rights Reserved. Privacy Policy

Contact us: hello@devglan.com