Core Java Projects with complete source code
2 4 6 8 10 12 14 16 .....
1 3 5 7 9 11 13 ....
3, 33, 333, 3333, 33333, 333333 ....
10 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1 10
1 2 4 7 11 16 22 29 .....
2 9 28 65 126 217 344
1 2 4 8 16 32 64 128 256 512 1024 ......
0 5 10 15 20 25 30 35 ....
1 1 2 3 5 8 13 21 34 55 89 .....
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 .....
1 3 6 10 15 21 28 36 45 55 .....
1 2 3 2 3 4 3 4 5 4 5 4 5 6 5 6 5 6 7 ....
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
6 5 4 3 2 1
6 5 4 3 2
6 5 4 3
6 5 4
6 5
6
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
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
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
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
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
1 0 1 0 1 0
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
A B C D E
A B C D
A B C
A B
A
E E E E E
D D D D
C C C
B B
A
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
* * * * *
* * * *
* * *
* *
*
A
A B
A B C
A B C D
A B C D E
A
B B
C C C
D D D D
E E E E E
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
```
36. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern34.java)
1
2 2
3 3 3
4 4 4 4 5 5 5 5 5
37. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern35.java)
*
* *
* * *
38. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern36.java)
E D C B A E D C B E D C E D E
39. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern37.java)
E E E E E D D D D C C C B B A
40. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern38.java)
5 4 3 2 1 5 4 3 2 5 4 3 5 4 5
41. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern39.java)
5 5 5 5 5 4 4 4 4 3 3 3 2 2 1
42. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern40.java)
A B C D E A B C D A B C A B A
43. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern41.java)
A A A A A B B B B C C C D D E
44. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern42.java)
1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
45. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern43.java)
46. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern44.java)
A A B A B C A B C D A B C D E
47. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern45.java)
48. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern53.java)
A B B C C C D D D D E E E E E
49. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern54.java)
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
50. Write a Java Program to print the following Pattern. [[Solution]](InterviewPrograms/src/com/java/patterns/Pattern55.java)
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
# Brackets or Parentheses Problems
1. Write a Java Program to find out whether the given string is **Balanced Parentheses** or NOT? [[Solution]](InterviewPrograms/src/com/java/parentheses/BalancedParentheses.java)
()() - VALID
(()) - VALID
())( - INVALID
(( - INVALID
2. Generate Balanced Parentheses of N pairs. [[Solution]](InterviewPrograms/src/com/java/parentheses/GenerateBalancedParentheses.java)
N = 2 N= 3
()() ()()()
(()) (())()
()(())
(()())
((()))
3. Generate All possible combinations of Parentheses.
N = 2 N= 3
() ()
()() ()()
(()) (())
()()()
(())()
()(())
(()())
((()))
4. Count the Number of possible combinations of Parentheses.
N = 2 N= 3
() ()
()() ()()
(()) (())
Output = 3 ()()()
(())()
()(())
(()())
((()))
Output = 8
# Java Interview Questions
1. What do you know about JVM, JRE and JDK?
2. Is JRE platform dependant or independent?
3. Which is ultimate base class in java class hierarchy? List the name of methods of it?
4. Which are the reference types in java?
5. What is narrowing and widening?
6. How will you print "Hello CDAC" statement on screen, without semicolon?
7. Can you write java application without main function? If yes, how?
8. What will happen, if we call main method in static block?
9. In System.out.println, What is meaning of every word?
10. How will you pass object to the function by reference?
11. What is constructor chaining? How can we achieve it in C++?
12. Which are the rules to overload method in sub class?
13. What is the difference between finalize and dispose?
14. What is shut down hook?
15. What is the difference between final, finally and finalize?
16. What is the difference between checked and unchecked exception?
17. What is exception chaining?
18. What is the difference between throw and throws?
19. In which case, finally block doesn’t execute?
20. What is upcasting?
21. What is dynamic method dispatch?
22. What do you know about final method?
23. What is the difference between abstract class and interface?
24. What is fragile base class problem and how can we overcome it?
25. Why java does not support multiple implementation inheritance?
26. What is marker interface? List the name of some marker interfaces?
27. What is the significance of marker interface?
28. What is the difference between Comparable and Comparator?
29. What is the difference between Array and ArrayList?
30. What is the difference between HashSet and HashMap?
31. What is the difference between HashTable and HashMap?
32. Which collection classes are synchronized?
33. What is the difference between ArrayList and Vector?
34. What is the difference between Enumeration and Iterator?
35. What is the difference between Iterator and ListIterator?
36. What is the difference between fail-fast and fail-safe iterator?
37. How can you copy elements of one collection into another without iterator?
38. What is the difference between String and StringBuffer?
39. What is the difference between StringBuffer and StringBuilder?
40. How can you check wheather string is palindrome or not?
41. Can we write multiple public classes in single .java file? If no why?
42. What is serialization and deserialization?
43. If serializable class do not contain serializable fields, what will happen? If its problematic then how will overcome it?
44. Which two techniques allow us to create new instance from existing one?
45. Which members do not serialize?
46. What is metadata? What is advantage of it?
47. What is bytecode?
48. What is reflection?
49. Which features of java makes it platform dependant?
50. What is applet?
51. Can you explain life cycle of applet?
52. Why AWT components are heavy weight component?
53. What is thread?
54. Which are the types of thread? What is the difference between them?
55. Explain life cycle of thread?
56. What is race condition? How can we overcome it?
57. What is synchronization? How can we achieve it?
58. How can we share object between the threads?
59. Why wait, notify and notifyall methods belongs to Object class instead of Thread class?
60. What do you know about volatile keyword in java?
61. What is the difference between Thread. Sleep and Thread.yield?
62. What is deadlock? How can we avoid it?
63. Why thread based multitasking is faster than process based multitasking?
64. When we should use Thread class and Runnable interface to create thread?
65. What is wild card? Which are the types of it?
66. What is the difference between TCP and UDP protocol?
67. What is socket?
68. When we should use socket and rmi?
69. How will you write code for linkedlist in java?
70. What is wrapper class? What is need of it?
71. What are the various access specifiers for Java classes?
72. What's the purpose of Static methods and static variables?
73. What is data encapsulation and what's its significance?
74. What is a singleton class? Give a practical example of its usage.
75. What are Loops in Java? What are three types of loops?