JAVA INTERVIEW – 1 PAGE QUICK NOTES
Java Platform Independent: Java compiles into bytecode which runs on JVM on any OS.
OOP Concepts:
• Inheritance – One class acquires another class properties
• Encapsulation – Binding data & methods together
• Abstraction – Hiding implementation details
• Polymorphism – One method, many forms (Overloading & Overriding)
Static Methods:
• Can be overloaded
• Cannot be overridden (compile-time binding)
Access Modifiers: Default, Private, Protected, Public
Constructors:
• Default – No arguments
• Parameterized – With arguments
Singleton Class: Only one object created using private constructor
== vs equals():
• == compares reference
• equals() compares values
Interface vs Abstract Class:
• Interface supports multiple inheritance
• Abstract class supports partial implementation
String vs StringBuffer vs StringBuilder:
• String – Immutable, slow
• StringBuffer – Mutable, thread-safe
• StringBuilder – Mutable, fastest
Variables:
• Local – Inside method/block
• Instance – Inside class, outside method
final / finally / finalize:
• final – restriction
• finally – always executes
• finalize – before garbage collection
HashMap vs Hashtable:
• HashMap – Not synchronized, faster
• Hashtable – Synchronized, slower
Threads:
• Extend Thread class
• Implement Runnable interface
SQL:
• DDL, DML, DCL, TCL
• GETDATE() – current date
• WHERE filters rows, HAVING filters groups
Spring vs Spring Boot:
• Spring – Manual configuration
• Spring Boot – Auto configuration, production ready