Interview Programs (In Java)
- Check the given number is EVEN or ODD. [Solution]
- Write a Java Program to find the Factorial of given number. [Solution]
- Find the Factorial of a number using Recursion. [Solution]
- Swap two numbers without using third variable approach 1. [Solution]
- Swap two numbers without using third variable approach 2. [Solution]
- Swap two numbers without using third variable approach 3. [Solution]
- How to check the given number is Positive or Negative in Java? [Solution]
- Write a Java Program to find whether given number is Leap year or NOT? [Solution]
- Write a Java Program to Print 1 To 10 Without Using Loop. [Solution]
- Write a Java Program to print the digits of a Given Number. [Solution]
- Write a Java Program to print all the Factors of the Given number. [Solution]
- Write a Java Program to find sum of the digits of a given number. [Solution]
- Write a Java Program to find the smallest of 3 numbers (a,b,c) without using < or > symbol? [Solution]
- How to add two numbers without using the arithmetic operators in Java? [Solution]
- Write a java program to Reverse a given number. [Solution]
- Write a Java Program to find GCD of two given numbers. [Solution]
- Write a java program to LCM of TWO given number. [Solution]
- Write a java program to LCM of TWO given number using Prime Factors method. [Solution]
- Check whether the Given Number is a Palindrome or NOT. [Solution]
- Write a Java Program to print all the Prime Factors of the Given Number. [Solution]
- Write a Java Program to check whether the Given Number is Prime Number or NOT. [Solution]
- Write a Java Program to print Prime Numbers from 1 to N. [Solution]
- Write a Java Program to check whether the given number is Armstrong Number or NOT. [Solution]
- Write a Java Program to print Armstrong Numbers between 1 to 1000. [Solution]
- Write a Java Program to check whether the given number is Perfect Number or NOT. [Solution]
- Write a Java Program to print Perfect Numbers between 1 to 1000. [Solution]
- Write a Java Program to check whether the given numbers are Amicable Numbers or NOT. [Solution]
- Write a Java Program to check whether the given number is Ramanujam's Number or NOT. [Solution]
- Write a Java Program check whether the given number is Automorphic Number or NOT. [Solution]
- Write a Java Program to print Automorphic Number between 1 to 1000. [Solution]
- Write a Java Program check whether the given number is Smith Number or NOT. [Solution]
- Write a Java Program to print Smith Number between 2 to 1000. [Solution]
- Write a Java Program to check whether given number is Kaprekar Number or NOT. [Solution]
- Write a Java Program to print Kaprekar Numbers between 1 to 1000. [Solution]
- Find the Largest Divisor. [Solution]
- Find the All Divisors of a Given number N. [Solution]
- How to check if two rectangles overlap with each other?
- Calculate the average of given array. [Solution]
- Find the second largest number in the given array. [Solution]
- Find the second minimum number in the given array. [Solution]
- Find the missing Number in the given array of 1 to N. [Solution]
- Write a Java Program to find the Intersection of two arrays. [Solution]
- Write a Java Program to find the Intersection of Two Sorted arrays. [Solution]
- Write a Java Program to find the Union of Two Arrays (UnSorted Array). [Solution]
- Write a Java Program to find the Union of Two Arrays (Sorted Arrays). [Solution]
- Write a Java Program to find the Union of Tow Arrays using HashSet. [Solution]
- Write a Java Program to Move all Zero to End of the Array. [Solution]
- Write a Java Program to Move all Zeros to Start of the Array. [Solution]
- Write a Java Program to Reverse the given array without using additional Array. [Solution]
- Write a program to find the Most Frequent Element in an given array. [Solution]
- Write a program to find the Most Frequent Element using Sorting. [Solution]
- Write a program to find the Most Frequent Element using HashTable. [Solution]
- Write a java program to Rotate the Given Array d times. [Solution]
- Find the pair of elements(X+Y) in the array whose sum is equal to given number Z. [Solution]
- Write a java program to check Given String is Palindrome or NOT. [Solution]
- How to Swap two Strings without using third (temporary) variable? [Solution]
- Write a java program to Reverse a String without using in-build function. [Solution]
- Write a java program to Count the Number of Words in a given String. [Solution]
- Write a java program to Count the Number of Vowels in the given string. [Solution]
- Check Given String is Rotation of Another String. [Solution]
- Write a Java Program to check two strings are Anagram to each other or NOT. [Solution]
- Write a Java program to find the Most Repeated Character in the Given String. [Solution]
- How do you count the Number of Words in a given String using Split method? [Solution]
- Write a Java Program to Print All Combinations of a given String. [Solution]
- Write a Java Program to Print All Permutations of a given String. [Solution]
- Write a Java Program to find All Subsets of a Given String using Bitwise approach. [Solution]
- Write a Java Program to find All Subsets of a Given String using Recursion approach. [Solution]
- Convert Decimal Number to Binary Number. [Solution]
- Convert Binary Number to Decimal Number. [Solution]
- Convert Decimal Number to Octal Number. [Solution]
- Convert Octal Number to Decimal Number. [Solution]
- Convert Decimal to Hexadecimal. [Solution]
- Convert Hexadecimal to Decimal. [Solution]
- Convert Octal to Binary Number. [Solution]
- Convert Binary Number to Octal. [Solution]
- Bubble Sort [Solution]
- Quick Sort [Solution]
- Selection Sort [Solution]
- Insertion Sort [Solution]
- Merge Sort [Solution]
- Linear Search [Solution]
- Binary Search [Solution]
- Write a Java Program to Add two Matrices. [Solution]
- Write a Java Program to Subtract Two Matrices. [Solution]
- Write a Java Program to Transpose a Matrix. [Solution]
- Write a Java Program to Multiply Two Matrices. [Solution]
- Write a Java Program to print the Matrix Spiral form. [Solution]
- Write a Java Program to check whether a Given Matrix is an Identity Matrix. [Solution]
- Check whether the Given Matrix is Sparse Matrix or NOT [Solution]
- Display the Lower Triangular Matrix [Solution]
- Display the Upper Triangular Matrix [Solution]
- Find sum of each row and each column of the Matrix. [Solution]
- Write the Java Program to print the following series EVEN number Series [Solution]
2 4 6 8 10 12 14 16 .....
- Write the Java Program to print the following series ODD number Series [Solution]
- Write the Java Program to print the following series Pattern Series [Solution]
3, 33, 333, 3333, 33333, 333333 ....
- Write the Java Program to print the following series [Solution]
10 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1 10
- Write the Java Program to print the following series QuadraticSequence [Solution]
1 2 4 7 11 16 22 29 .....
- Write the Java Program to print the following series [Solution]
- Write the Java Program to print the following series Geometric Progression [Solution]
1 2 4 8 16 32 64 128 256 512 1024 ......
- Write the Java Program to print the following series Arithmetic Progression [Solution]
0 5 10 15 20 25 30 35 ....
- Write the Java Program to print the following series Fibonacci Series [Solution]
1 1 2 3 5 8 13 21 34 55 89 .....
- Write the Java Program to print the following series Prime Number Series [Solution]
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 .....
- Write the Java Program to print the following series Triangular Number Series [Solution]
1 3 6 10 15 21 28 36 45 55 .....
- Write the Java Program to print the following series
1 2 3 2 3 4 3 4 5 4 5 4 5 6 5 6 5 6 7 ....
- Write a Program to print Floyd's triangle? [Solution]
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
- Write a Program to print Pascal's triangle?
- Write a Java Program to print the following Pattern [Solution]
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
- Write a Java Program to print the following Pattern. [Solution]
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
- Write a Java Program to print the following Pattern. [Solution]
6 5 4 3 2 1
6 5 4 3 2
6 5 4 3
6 5 4
6 5
6
- Write a Java Program to print the following Pattern. [Solution]
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
- Write a Java Program to print the following Pattern. [Solution]
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
- Write a Java Program to print the following Pattern. [Solution]
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
- Write a Java Program to print the following Pattern. [Solution]
1 2 3 4 5 6
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6
5 6
4 5 6
3 4 5 6
2 3 4 5 6
1 2 3 4 5 6
- Write a Java Program to print the following Pattern. [Solution]
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
- Write a Java Program to print the following Pattern. [Solution]
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
1 0 1 0 1 0
- Write a Java Program to print the following Pattern.
1 1 1 1 1 1
1 1 1 1 2 2
1 1 1 3 3 3
1 1 4 4 4 4
1 5 5 5 5 5
6 6 6 6 6 6
- Write a Java Program to print the following Pattern. [Solution]
9 9 9 9 9 9 9 9 9
7 7 7 7 7 7 7
5 5 5 5 5
3 3 3
1
- Write a Java Program to print the following Pattern. [Solution]
5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4
3 3 3 3 3
2 2 2
1
- Write a Java Program to print the following Pattern. [Solution]
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
- Write a Java Program to print the following Pattern. [Solution]
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
- Write a Java Program to print the following Pattern. [Solution]
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
- Write a Java Program to print the following Pattern. [Solution]
A
B A B
C B A B C
D C B A B C D
E D C B A B C D E
- Write a Java Program to print the following Pattern. [Solution]
0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
- Write a Java Program to print the following Pattern. [Solution]
A
C B A
E D C B A
G F E D C B A
I H G F E D C B A
- Write a Java Program to print the following Pattern. [Solution]
A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
- Write a Java Program to print the following Pattern. [Solution]
1
3 2 1
5 4 3 2 1
7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1
- Write a Java Program to print the following Pattern. [Solution]
1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
- Write a Java Program to print the following Pattern. [Solution]
A
C C C
E E E E E
G G G G G G G
I I I I I I I I I
- Write a Java Program to print the following Pattern. [Solution]
A
B B B
C C C C C
D D D D D D D
E E E E E E E E E
- Write a Java Program to print the following Pattern. [Solution]
1
3 3 3
5 5 5 5 5
7 7 7 7 7 7 7
9 9 9 9 9 9 9 9 9
- Write a Java Program to print the following Pattern. [Solution]
1
2 2 2
3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5
- Write a Java Program to print the following Pattern. [Solution]
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
- Write a Java Program to print the following Pattern. [Solution]
A B C D E
A B C D
A B C
A B
A
- Write a Java Program to print the following Pattern. [Solution]
E E E E E
D D D D
C C C
B B
A
- Write a Java Program to print the following Pattern. [Solution]
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
- Write a Java Program to print the following Pattern. [Solution]
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
- Write a Java Program to print the following Pattern. [Solution]
* * * * *
* * * *
* * *
* *
*
- Write a Java Program to print the following Pattern. [Solution]
A
A B
A B C
A B C D
A B C D E
- Write a Java Program to print the following Pattern. [Solution]
A
B B
C C C
D D D D
E E E E E
- Write a Java Program to print the following Pattern. [Solution]
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
- Write a Java Program to print the following Pattern. [Solution]
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
- Write a Java Program to print the following Pattern. [Solution]
*
* *
* * *
* * * *
* * * * *
- Write a Java Program to print the following Pattern. [Solution]
E D C B A
E D C B
E D C
E D
E
- Write a Java Program to print the following Pattern. [Solution]
E E E E E
D D D D
C C C
B B
A
- Write a Java Program to print the following Pattern. [Solution]
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
- Write a Java Program to print the following Pattern. [Solution]
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
- Write a Java Program to print the following Pattern. [Solution]
A B C D E
A B C D
A B C
A B
A
- Write a Java Program to print the following Pattern. [Solution]
A A A A A
B B B B
C C C
D D
E
- Write a Java Program to print the following Pattern. [Solution]
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
- Write a Java Program to print the following Pattern. [Solution]
* * * * *
* * * *
* * *
* *
*
- Write a Java Program to print the following Pattern. [Solution]
A
A B
A B C
A B C D
A B C D E
- Write a Java Program to print the following Pattern. [Solution]
*
* *
* * *
* * * *
* * * * *
- Write a Java Program to print the following Pattern. [Solution]
A
B B
C C C
D D D D
E E E E E
- Write a Java Program to print the following Pattern. [Solution]
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
- Write a Java Program to print the following Pattern. [Solution]
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Brackets or Parentheses Problems
- Write a Java Program to find out whether the given string is Balanced Parentheses or NOT? [Solution]
()() - VALID
(()) - VALID
())( - INVALID
(( - INVALID
- Generate Balanced Parentheses of N pairs. [Solution]
N = 2 N= 3
()() ()()()
(()) (())()
()(())
(()())
((()))
- Generate All possible combinations of Parentheses.
N = 2 N= 3
() ()
()() ()()
(()) (())
()()()
(())()
()(())
(()())
((()))
- Count the Number of possible combinations of Parentheses.
N = 2 N= 3
() ()
()() ()()
(()) (())
Output = 3 ()()()
(())()
()(())
(()())
((()))
Output = 8
- What do you know about JVM, JRE and JDK?
- Is JRE platform dependant or independent?
- Which is ultimate base class in java class hierarchy? List the name of methods of it?
- Which are the reference types in java?
- What is narrowing and widening?
- How will you print "Hello CDAC" statement on screen, without semicolon?
- Can you write java application without main function? If yes, how?
- What will happen, if we call main method in static block?
- In System.out.println, What is meaning of every word?
- How will you pass object to the function by reference?
- What is constructor chaining? How can we achieve it in C++?
- Which are the rules to overload method in sub class?
- What is the difference between finalize and dispose?
- What is shut down hook?
- What is the difference between final, finally and finalize?
- What is the difference between checked and unchecked exception?
- What is exception chaining?
- What is the difference between throw and throws?
- In which case, finally block doesn’t execute?
- What is upcasting?
- What is dynamic method dispatch?
- What do you know about final method?
- What is the difference between abstract class and interface?
- What is fragile base class problem and how can we overcome it?
- Why java does not support multiple implementation inheritance?
- What is marker interface? List the name of some marker interfaces?
- What is the significance of marker interface?
- What is the difference between Comparable and Comparator?
- What is the difference between Array and ArrayList?
- What is the difference between HashSet and HashMap?
- What is the difference between HashTable and HashMap?
- Which collection classes are synchronized?
- What is the difference between ArrayList and Vector?
- What is the difference between Enumeration and Iterator?
- What is the difference between Iterator and ListIterator?
- What is the difference between fail-fast and fail-safe iterator?
- How can you copy elements of one collection into another without iterator?
- What is the difference between String and StringBuffer?
- What is the difference between StringBuffer and StringBuilder?
- How can you check wheather string is palindrome or not?
- Can we write multiple public classes in single .java file? If no why?
- What is serialization and deserialization?
- If serializable class do not contain serializable fields, what will happen? If its problematic then how will overcome it?
- Which two techniques allow us to create new instance from existing one?
- Which members do not serialize?
- What is metadata? What is advantage of it?
- What is bytecode?
- What is reflection?
- Which features of java makes it platform dependant?
- What is applet?
- Can you explain life cycle of applet?
- Why AWT components are heavy weight component?
- What is thread?
- Which are the types of thread? What is the difference between them?
- Explain life cycle of thread?
- What is race condition? How can we overcome it?
- What is synchronization? How can we achieve it?
- How can we share object between the threads?
- Why wait, notify and notifyall methods belongs to Object class instead of Thread class?
- What do you know about volatile keyword in java?
- What is the difference between Thread. Sleep and Thread.yield?
- What is deadlock? How can we avoid it?
- Why thread based multitasking is faster than process based multitasking?
- When we should use Thread class and Runnable interface to create thread?
- What is wild card? Which are the types of it?
- What is the difference between TCP and UDP protocol?
- What is socket?
- When we should use socket and rmi?
- How will you write code for linkedlist in java?
- What is wrapper class? What is need of it?
- What are the various access specifiers for Java classes?
- What's the purpose of Static methods and static variables?
- What is data encapsulation and what's its significance?
- What is a singleton class? Give a practical example of its usage.
- What are Loops in Java? What are three types of loops?