# java programs

- 15 December
### How to find GCD and LCM of two numbers in java

In this post, we will see how to find Greatest common divisor(GCD) and Least Common Multiple(LCM) in java. GCD is calculated using Euclidean algorithm and LCM is calculated using reduction by GCD Eucid algo for calculating GCD is: Lets say , there are two numbers , a and b so GCD of two numbers = […]

- 10 July
### How to find prime factors of a number in java

In this post, we will see how to find prime factors of a number in java. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The prime factors of a number are all of the prime numbers that will exactly divide the given number. […]

- 09 July
### Palindrome program in java

In this article, we will see how to implement palindrome program in java. A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed. For example: 12121 is palindrome as it reads same forward or reversed. madam is also a palindrome . This is very […]

- 09 July
### java program to check prime number

This is easy question. It may not be asked you directly, but you can use this program to create many other complex program. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Program logic: If any number which is not divisible by any other […]

- 16 September
### Java program to find missing number in an array

If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. This is one of basic coding interview question asked in my interviews. Problem : You are given an integer array containing 1 to n but one of the number from 1 to n in the array […]

- 24 September
### Java program to find second largest number in an array

If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. In this post, we will see how to find the second largest number in an array. Problem : Given an unsorted array, you need to find the second largest element in the array in o(n) time […]

- 23 August
### Java Interview Programs

I have been posting java interview programs on various topics such as Binary tree, LinkedList , String, Number, ArrayList, HashMap etc. So I am consolidating list of java interview programs to create an index post. I will keep adding links to this post whenever I add any new program. These are frequently asked java programs […]

- 10 June
### Java Interview Programs for Freshers

In this tutorial, we will see Java interview programs for freshers. This interview programs will help freshers to crack Java interview. Here is the list of Top 10 Java interview Programs for Freshers. Question 1: Check if number is odd or even? Answer: It is a very basic question. You need to check remainder value […]

- 02 August
### How to find length of string in java without using length() method

One of the interview question is “How to find length of string in java without using length() method.” There are many ways to find length of String. Some of them are : Using toCharArray is simplest solution. Using toCharArray Logic Convert string to char array using toCharArray method Iterate over char array and incrementing length […]