🔹 Basics
1. What is Java? Why is it platform independent?
👉 Java is an object-oriented programming language. It is platform independent because Java
code is converted into bytecode, which runs on JVM.
2. Explain JDK, JRE, JVM.
👉 JDK = Development tools + JRE
👉 JRE = JVM + libraries
👉 JVM = Runs bytecode
3. What are the features of Java?
👉 OOP, Platform independent, Secure, Robust, Multithreaded
4. Why is Java object-oriented?
👉 Because it supports class, object, inheritance, polymorphism, abstraction, encapsulation.
5. What is bytecode?
👉 Intermediate code generated by Java compiler that runs on JVM.
🔹 Data Types & Variables
6. What are primitive and non-primitive data types?
👉 Primitive store values (int, char)
👉 Non-primitive store reference (String, array)
7. Why is String immutable?
👉 For security, memory efficiency, and thread safety.
8. Difference between == and .equals()?
👉 == compares reference
👉 .equals() compares content
9. What is type casting?
👉 Converting one data type into another.
10. What is final keyword?
👉 Final variable → constant
👉 Final method → can’t override
👉 Final class → can’t inherit
🔹 OOP Concepts
11. What is encapsulation?
👉 Binding data and methods using private variables & public methods.
12. What is inheritance?
👉 One class acquiring properties of another using extends.
13. Explain polymorphism.
👉 One method behaves differently based on object or parameters.
14. Difference between overloading & overriding?
👉 Overloading → same method name, different parameters
👉 Overriding → same method in parent & child
15. What is abstraction?
👉 Hiding implementation details and showing only functionality.
🔹 Classes & Objects
16. What is class and object?
👉 Class is a blueprint
👉 Object is instance of class
17. What is constructor?
👉 Special method to initialize object.
18. Can constructor be overloaded?
👉 Yes
19. What is this keyword?
👉 Refers to current object.
20. Can constructor be private?
👉 Yes (used in Singleton class).
🔹 Inheritance & Keywords
21. Difference between extends and implements?
👉 extends → class to class
👉 implements → class to interface
22. What is super keyword?
👉 Used to access parent class methods or constructor.
23. Can we achieve multiple inheritance in Java?
👉 Not with classes, only with interfaces.
24. Why Java doesn’t support multiple inheritance with classes?
👉 To avoid ambiguity (diamond problem).
25. Can a class be final?
👉 Yes, final class can’t be inherited.
🔹 Interface & Abstract Class
26. Difference between abstract class and interface?
👉 Abstract class → methods + variables
👉 Interface → abstraction only
27. Can interface have methods with body?
👉 Yes, after Java 8 (default methods).
28. Can class implement multiple interfaces?
👉 Yes
29. Can abstract class have constructor?
👉 Yes
30. When to use interface vs abstract class?
👉 Interface → multiple inheritance
👉 Abstract class → base implementation
🔹 Exception Handling
31. What is exception?
👉 Runtime error that disrupts normal flow.
32. Checked vs unchecked exception?
👉 Checked → compile time
👉 Unchecked → runtime
33. What is try-catch-finally?
👉 Used to handle exceptions.
34. Can we have multiple catch blocks?
👉 Yes
35. throw vs throws?
👉 throw → explicitly throw exception
👉 throws → declare exception
🔹 Strings
36. Difference between String, StringBuffer, StringBuilder?
👉 String → immutable
👉 StringBuffer → thread-safe
👉 StringBuilder → faster, not thread-safe
37. What is string pool?
👉 Memory area where strings are stored.
38. How to reverse a string?
👉 Using loop or StringBuilder reverse().
39. equals() vs compareTo()?
👉 equals → true/false
👉 compareTo → numeric difference
🔹 Arrays & Loops
40. What is array?
👉 Collection of same type elements.
41. Array vs ArrayList?
👉 Array → fixed size
👉 ArrayList → dynamic size
42. What is enhanced for loop?
👉 Loop used to iterate without index.
43. Can array store objects?
👉 Yes
44. How to sort array?
👉 Using loops or [Link]().
🔹 Collections
45. Difference between List, Set, Map?
👉 List → duplicates allowed
👉 Set → no duplicates
👉 Map → key-value pair
46. ArrayList vs LinkedList?
👉 ArrayList → fast access
👉 LinkedList → fast insertion
47. HashMap vs Hashtable?
👉 HashMap → not synchronized
👉 Hashtable → synchronized
48. What is Iterator?
👉 Used to traverse collection.
49. Why Map doesn’t allow duplicate keys?
👉 Keys must be unique to identify values.
🔹 Multithreading
50. What is thread?
👉 Lightweight process.
51. Process vs thread?
👉 Process → heavy
👉 Thread → lightweight
52. How to create thread?
👉 By extending Thread or implementing Runnable.
53. run() vs start()?
👉 start() creates new thread
👉 run() runs like method
54. What is synchronization?
👉 Controls shared resources.
🔹 Keywords
55. What is static keyword?
👉 Belongs to class, not object.
56. Can static method be overridden?
👉 No
57. What is transient?
👉 Variable not serialized.
58. What is volatile?
👉 Ensures visibility in multithreading.
59. What is instanceof?
👉 Checks object type.
🔹 Coding Logic
60. Swap without third variable?
👉 Use a = a + b; b = a - b; a = a - b;
61. Find largest in array?
👉 Compare using loop.
62. Palindrome string?
👉 Compare original & reversed string.
63. What happens if main() is private?
👉 JVM cannot access it → Runtime error.