Java Concept OOP Principle
Function/Method Overloading Polymorphism (Compile-time)
Function/Method Overriding Polymorphism (Runtime)
private variables Encapsulation
Abstract method Abstraction
Interface Abstraction
extends keyword Inheritance
Method call using object Message Passing
Specifier Scope
public Everywhere
protected Package + subclass
default Package only
private Class only
1. private NOT inherited
2. protected inherited (even in different package)
3. default NOT accessible outside package
4. public fully accessible
Variable Type Definition Where Declared Scope Example
Local Declared inside a Inside method Only within void fun(){ int
Variable method/block method x=10; }
Instance Belongs to object Inside class Each object has class A { int
Variable (outside method) its own copy x=10; }
Static Shared by all objects Inside class with One copy for class A { static
Variable static keyword all objects int x=10; }
Parameter Passed to methods Method Used inside void fun(int x)
Variable arguments method {}
Data Size Example
Type
byte 1 byte (8-bit) byte a = 10;
short 2 bytes (16-bit) short a = 100;
int 4 bytes (32-bit) int a = 1000;
long 8 bytes (64-bit) long a = 10000L;
float 4 bytes (32-bit) float a = 10.5f;
double 8 bytes (64-bit) double a = 10.55;
char 2 bytes (16-bit) char ch = 'A';
boolean 1 bit (logical) boolean b = true;
Pure Function Impure Function
Does not change original Changes original data or depends on external state
data
No modification May modify arguments
Only on input parameters May depend on global/instance variables
No side effects Has side effects
Same input → same output Output may vary
Works like Call by Value Often behaves like Call by Reference (conceptually)