- Clone the repository from here
https://github.com/sangaryousmane/java-interview-questions.git
- Navigate into the /src directory if you need the answers to all the questions but make sure to try the questions on your own first
- The /src directory has subdirectories based on your need. For instance, there is a subdirectory for Basics, Arrays, Search Algorithms et al.
- Make sure and practice more, don't copy and paste but type the codes instead.
Check all the manual of this part in this link: Here
- Input a year and find whether it is a leap year or not.
- Take two numbers and print the sum of both.
- Take a number as input and print the multiplication table for it.
- Take 2 numbers as inputs and find their HCF and LCM.
- Keep taking numbers as inputs till the user enters ‘x’, after that print sum of all.
Check all the manual of this part in this link: Here
- Write a program to print whether a number is even or odd, also take input from the user.
- Take name as input and print a greeting message for that particular name.
- Write a program to input principal, time, and rate (P, T, R) from the user and find Simple Interest.
- Take in two numbers and an operator (+, -, *, /) and calculate the value. (Use if conditions)
- Take 2 numbers as input and print the largest number.
- Input currency in rupees and output in USD.
- To calculate Fibonacci Series up to n numbers.
- To find out whether the given String is Palindrome or not.
- To find Armstrong Number between two given number.
Check all the manual of this part in this link: Here
- Area Of Circle Java Program
- Area Of Triangle
- Area Of Rectangle Program
- Area Of Isosceles Triangle
- Area Of Parallelogram
- Area Of Rhombus
- Area Of Equilateral Triangle
- Perimeter Of Circle
- Perimeter Of Equilateral Triangle
- Perimeter Of Parallelogram
- Perimeter Of Rectangle
- Perimeter Of Square
- Perimeter Of Rhombus
- Volume Of Cone Java Program
- Volume Of Prism
- Volume Of Cylinder
- Volume Of Sphere
- Volume Of Pyramid
- Curved Surface Area Of Cylinder
- Total Surface Area Of Cube
- Fibonacci Series In Java Programs
- Subtract the Product and Sum of Digits of an Integer
- Input a number and print all the factors of that number (use loops).
- Take integer inputs till the user enters 0 and print the sum of all numbers (HINT: while loop)
- Take integer inputs till the user enters 0 and print the largest number from all.
- Addition Of Two Numbers
- Factorial Program In Java
- Calculate Electricity Bill
- Calculate Average Of N Numbers
- Calculate Discount Of Product
- Calculate Distance Between Two Points
- Calculate Commission Percentage
- Power In Java
- Calculate Depreciation of Value
- Calculate Batting Average
- Calculate CGPA Java Program
- Compound Interest Java Program
- Calculate Average Marks
- Sum Of N Numbers
- Armstrong Number In Java
- Find Ncr & Npr
- Reverse A String In Java
- Find if a number is palindrome or not
- Future Investment Value
- HCF Of Two Numbers Program
- LCM Of Two Numbers
- Java Program Vowel Or Consonant
- Perfect Number In Java
- Check Leap Year Or Not
- Sum Of A Digits Of Number
- Kunal is allowed to go out with his friends only on the even days of a given month. Write a program to count the number of days he can go out in the month of August.
- Write a program to print the sum of negative numbers, sum of positive even numbers and the sum of positive odd numbers from a list of numbers (N) entered by the user. The list terminates when the user enters a zero.
- Define two methods to print the maximum and the minimum number respectively among three numbers entered by the user.
- Define a program to find out whether a given number is even or odd.
- A person is eligible to vote if his/her age is greater than or equal to 18. Define a method to find out if he/she is eligible to vote.
- Write a program to print the sum of two numbers entered by user by defining your own method.
- Define a method that returns the product of two numbers entered by user.
- Write a program to print the circumference and area of a circle of radius entered by user by defining your own method.
- Define a method to find out if a number is prime or not.
- Write a program that will ask the user to enter his/her marks (out of 100). Define a method that will display grades according to the marks entered as below:
Marks Grade 91-100 AA 81-90 AB 71-80 BB 61-70 BC 51-60 CD 41-50 DD <=40 Fail
10. Write a program to print the factorial of a number by defining a method named 'Factorial'. Factorial of any number n is represented by n! and is equal to 1 * 2 * 3 * .... * (n-1) *n. E.g.-
4! = 1 * 2 * 3 * 4 = 24 3! = 3 * 2 * 1 = 6 2! = 2 * 1 = 2 Also, 1! = 1 0! = 1 12. Write a function to find if a number is a palindrome or not. Take number as parameter. 13. Convert the programs in flow of program, first java, conditionals & loops assignments into functions. 14. Write a function to check if a given triplet is a Pythagorean triplet or not. (A Pythagorean triplet is when the sum of the square of two numbers is equal to the square of the third number). 15. Write a function that returns all prime numbers between two given numbers. 16. Write a function that returns the sum of first n natural numbers.
- Build Array from Permutation
- Concatenation of Array
- Running Sum of 1d Array
- Richest Customer Wealth
- Shuffle the Array
- Kids With the Greatest Number of Candies
- Number of Good Pairs
- How Many Numbers Are Smaller Than the Current Number
- Create Target Array in the Given Order
- Check if the Sentence Is Pangram
- Count Items Matching a Rule
- Find the Highest Altitude
- Flipping an Image
- Cells with Odd Values in a Matrix
- Matrix Diagonal Sum
- Find Numbers with Even Number of Digits
- Transpose Matrix
- Add to Array-Form of Integer
- Maximum Population Year
- Determine Whether Matrix Can Be Obtained By Rotation
- Two Sum
- Find N Unique Integers Sum up to Zero
- Lucky Number In a Matrix
- Maximum Subarray
- Reshape the Matrix
- Plus One
- Remove Duplicates from Sorted Array
- Minimum Cost to Move Chips to The Same Position
- Spiral Matrix
- Spiral Matrix II
- Spiral Matrix III
- Set Matrix Zeroes
- Product of Array Except Self
- Find First and Last Position of Element in Sorted Array
- Jump Game
- Rotate Array
- Sort Colors
- House Robber
- Hard
- Max Value of Equation
- First Missing Positive
- Good Array