INTERVIEW QUESTIONS
1. What are the features of Java?
2. What is the difference between JDK, JRE, and JVM?
3. How does Java achieve platform independence?
4. What happens internally when you execute a Java program?
5. What is the difference between primitive and non-primitive data
types?
6. What is the difference between local, instance, and static
variables?
7. What are tokens in Java?
8. What are the different types of tokens in Java?
9. What is the difference between keywords, identifiers, literals,
operators, and separators in Java?
10. What are the rules for naming identifiers in Java? Can keywords
be used as identifiers?
11. What are literals in Java? Explain the different types of literals
with examples.
12. What are the four pillars of Object-Oriented Programming?
13. Explain encapsulation with an example.
14. Explain inheritance and its types.
15. What is polymorphism? Explain compile-time and runtime
polymorphism.
16. What is abstraction?
17. What is the difference between abstraction and encapsulation?
18. What is the difference between method overloading and method
overriding?
19. Why doesn't Java support multiple inheritance through classes?
20. What is the difference between a class and an object?
21. How do you create an object in Java?
22. What is the difference between the this keyword and the super
keyword?
23. What is the purpose of the static keyword?
24. What are instance variables and static variables?
25. What are inner classes? What are their types?
26. What is a constructor?
27. What are the different types of constructors?
28. What is constructor overloading?
29. What is the difference between a constructor and a method?
30. What is an array? How do you declare and initialize it?
31. How do you find the largest and second-largest element in an
array?
32. How do you remove duplicate elements from an array?
33. How do you reverse an array without using another array?
34. Why is String immutable in Java?
35. What is the String Constant Pool?
36. What is the difference between == and equals() for strings?
37. What is the difference between String, StringBuilder, and
StringBuffer?
38. What happens when you create a string using the new keyword?
39. How do you reverse a string?
40. How do you check whether two strings are anagrams?
41. What is the difference between an interface and an abstract
class?
42. Can an interface have constructors, variables, and methods?
43. Can an abstract class have constructors and concrete methods?
44. When would you choose an interface over an abstract class?
45. What is the difference between checked and unchecked
exceptions?
46. What is the difference between throw and throws?
47. What is the purpose of the finally block? When is it not
executed?
48. What is a custom exception, and how do you create one?