1. INTRODUCTION TO JAVA
1.1 What is Java?
-
Java is a high-level, object-oriented, platform-independent programming language.
-
Developed by James Gosling at Sun Microsystems (1995).
-
“Write Once, Run Anywhere” – bytecode runs on JVM on any OS.
1.2 Features of Java
-
Simple
-
Object-Oriented
-
Platform Independent
-
Secure
-
Robust
-
Portable
-
High Performance (JIT compiler)
-
Multithreaded
-
Distributed
-
Dynamic
1.3 JVM, JDK, JRE
JDK (Java Development Kit)
-
Full package: JRE + compiler (javac) + tools.
JRE (Java Runtime Environment)
-
Provides libraries + JVM to run Java programs.
JVM (Java Virtual Machine)
-
Converts bytecode to machine code.
-
Handles: memory, garbage collection, security.
2. BASICS OF JAVA
2.1 Data Types
Primitive
-
byte (1 byte)
-
short (2 bytes)
-
int (4)
-
long (8)
-
float (4)
-
double (8)
-
char (2)
-
boolean (1 bit)
Non-Primitive
-
String
-
Arrays
-
Classes, Objects
2.2 Variables
-
Instance variables – inside class, outside method.
-
Local variables – inside method.
-
Static variables – shared across objects.
2.3 Operators
-
Arithmetic: + - * / %
-
Relational: < > <= >= == !=
-
Logical: && || !
-
Assignment: = += -= *=
-
Unary: ++ --
-
Ternary: ? :
2.4 Control Statements
Decision Making
-
if
-
if-else
-
else-if ladder
-
switch
Loops
-
for
-
while
-
do-while
-
for-each
3. OBJECT-ORIENTED PROGRAMMING (OOP)
3.1 Class & Object
Class → blueprint
Object → instance
3.2 Constructors
-
Called automatically at object creation.
Types:
-
Default
-
Parameterized
-
Copy constructor (via object reference)
3.3 OOP Pillars
1️⃣ Encapsulation
-
Binding data + methods into one unit.
-
Achieved using private variables and public getters/setters.
2️⃣ Inheritance
-
Process of acquiring properties of another class.
Types:
-
Single
-
Multilevel
-
Hierarchical
(Java does NOT support multiple inheritance using classes — but interfaces allow it.)
3️⃣ Polymorphism
Compile-time → method overloading
Runtime → method overriding
4️⃣ Abstraction
-
Hiding implementation details.
-
Achieved by:
-
abstract class
-
interface
-
4. ACCESS MODIFIERS
-
public – accessible everywhere
-
private – within class only
-
protected – within package + subclasses
-
default – package-private
5. KEYWORDS
-
static – shared across objects
-
this – refers to current object
-
super – refers to parent class
-
final – constant / no overriding / no inheritance
-
return – returns value
-
break, continue – control flow
6. EXCEPTION HANDLING
6.1 Why Exception Handling?
To handle runtime errors gracefully.
6.2 Types of Exceptions
Checked exceptions
-
Must be handled at compile time
Examples: IOException, SQLException
Unchecked exceptions
-
Runtime errors
Examples: NullPointerException, ArithmeticException
6.3 Keywords
-
try
-
catch
-
finally
-
throw (used inside method)
-
throws (used in method declaration)
7. JAVA COLLECTIONS FRAMEWORK
Used to store and manipulate groups of objects.
7.1 Interfaces
-
List
-
Set
-
Map
-
Queue
7.2 Implementing Classes
List
-
ArrayList (dynamic array)
-
LinkedList (doubly linked list)
-
Vector
-
Stack
Set
-
HashSet
-
LinkedHashSet
-
TreeSet (sorted)
Map
-
HashMap
-
LinkedHashMap
-
TreeMap
-
Hashtable
8. MULTITHREADING
8.1 Thread Creation
-
Extend
Threadclass -
Implement
Runnableinterface
8.2 Thread Methods
-
start()
-
run()
-
sleep()
-
join()
-
yield()
-
setPriority()
8.3 Synchronization
Prevents concurrent access of shared resources.
Types:
-
Method synchronization
-
Block synchronization
-
Static synchronization
9. JAVA MEMORY MANAGEMENT
Heap – stores objects
Stack – stores method calls, local variables
Garbage Collector – removes unused objects
GC Algorithms:
-
Mark & Sweep
-
Generational GC
10. STRING HANDLING
String (immutable)
StringBuilder (mutable, fast)
StringBuffer (thread-safe)
11. FILE HANDLING (java.io & java.nio)
Classes:
-
FileInputStream
-
FileOutputStream
-
BufferedReader
-
FileReader
-
PrintWriter
12. JDBC (Database Connectivity)
Steps:
-
Load driver
-
Create connection
-
Create statement
-
Execute query
-
Process results
-
Close connection
13. JAVA 8 FEATURES
-
Lambda Expressions
-
Functional Interfaces
-
Stream API
-
Default & Static Methods in Interface
-
Method References
-
Optional Class
14. SPRING (BRIEF)
If you need full Spring notes, I can prepare separately.
-
Spring Core – IoC, Dependency Injection
-
Spring MVC – Web apps
-
Spring Boot – Auto configuration, easy setup
-
Spring Data JPA – ORM
-
Spring Security – Authentication
15. MOST IMPORTANT INTERVIEW QUESTIONS
-
Difference between JDK, JRE, JVM
-
Overloading vs Overriding
-
Interface vs Abstract Class
-
HashMap vs Hashtable
-
String vs StringBuilder
-
What is garbage collection?
-
Checked vs Unchecked exceptions
-
How HashMap works internally?
-
Why Java is platform independent?
-
What is multithreading?
.png)
0 Comments